Logic and Design

Logic and Design

Please help me with this Write a program that prompts and accepts a number between 1 and 12. After getting the input, display the number with the appropriate month. (example: This is the 1st month¦January, This is the 2nd month¦February, This is the 12th month¦December).

Thanks

View Answers

January 23, 2012 at 5:47 PM

import java.text.*;
import java.util.*;

class PrintMonth 
{
    public static String getMonthForInt(int m) {
    String month = "invalid";
    DateFormatSymbols dfs = new DateFormatSymbols();
    String[] months = dfs.getMonths();
    if (m >= 0 && m <= 11 ) {
        month = months[m];
    }
    return month;
}
    public static void main(String[] args) 
    {
        Scanner input=new Scanner(System.in);
        System.out.print("Enter number between 1 and 12: ");
        int num=input.nextInt()-1;
        System.out.println("Month is: "+getMonthForInt(num));
    }
}

January 23, 2012 at 6:22 PM

	//please reply if my post really helps
	import java.io.*;
	class Month
	{
	public static void main()throws IOException
	{
	BufferedReader in= new BufferedReader(new InputStreamReader(System.in));
	System.out.println("Enter number between 1 and 12: ");
	int num=Integer.parseInt(in.readLine());
	String mn[]={January,February,March,April,May,June,July,August,September,Octobr,November,December};
	if(num==1)
	System.out.println(num+"st month "+mn[num-1];
	else if(num==2)
	System.out.println(num+"nd month "+mn[num-1];
	else if(i==3)
	System.out.println(num+"rd month "+mn[num-1];
	else
	System.out.println(num+"th month "+mn[num-1];
	}
	}



January 23, 2012 at 6:24 PM

//copy the previous code in notepad and run in bluej









Related Tutorials/Questions & Answers:
Logic and Design
Logic and Design  Please help me with this Write a program that prompts and accepts a number between 1 and 12. After getting the input, display the number with the appropriate month. (example: This is the 1st month¦January
LOGIC
LOGIC  hey guys..i have my exams coming in somedays and it would be really helpful if someone explained how to develop the logic of any program
Advertisements
LOGIC
LOGIC  hey guys..i have my exams coming in somedays and it would be really helpful if someone explained how to develop the logic of any program
Logic and desgin
Logic and desgin  How would this be put in visual logic symbol
Logic and Degin
Logic and Degin  Need help in writing a pseudocode for this can so please help me with this just need to get started. In this lab, you are going... will modify the existing code to create a modularized design. Load the array via
Logic Building
Logic Building  I wanted to devlop my logic ? How can i do so ? Can i start with java or i need to do c++ before
Logic Iterate.
Logic Iterate.  I have one doubt about logic:iterate. I use text feild inside of logic:iterate , there is possible will generate N no of rows (text feild) inside of iterate. my doubt is how to get the Paritcular rows text
Logic Iterate.
Logic Iterate.  logic iterate Struts I have one doubt about logic:iterate. I use text field inside of logic:iterate , there is possible... the Particular rows text value. for example: print("<logic:iterate id="xid
Business logic vs Presentation logic - JSP-Servlet
Business logic vs Presentation logic  what is the difference between Business logic and Presentation logic
What is programming logic ?
What is programming logic ?  What is programming logic
logic-iterate
logic-iterate  in my code i am using for-each loop for displaying data i want use tag to display data how to use plase help me <%@ page import="java.sql.*" %> <%String[] id = (String[])session.getAttribute("ids
java design
java design  What is design by contract
Design pattern
Design pattern  explain factory pattern
WEB LOGIC - JSP-Servlet
WEB LOGIC project  I want the procedure to run a project in we logic server
the business logic is executed.
the business logic is executed.  In which method of Action class the business logic is executed
ModuleNotFoundError: No module named 'logic'
ModuleNotFoundError: No module named 'logic'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'logic' How to remove the ModuleNotFoundError: No module named 'logic'
what is the logic of this pattern?
what is the logic of this pattern?   1 121 12321 1234321
java - Design concepts & design patterns
java  give the code to design the hotel management software
J2EE design patterns - Design concepts & design patterns
J2EE design patterns  Hi all, could any one send me design patterns links. its very utgent. thanks, lakshminarayana.  Hi Friend, For J2EE Singleton Pattern,visit the following link: http
Design patterns - Design concepts & design patterns
Design patterns  I am new to design patterns and desigining . Please refer me some tutorial or pdfs of design patterns and desigining in easy.... It is this solution when documented and used over and over becomes a design pattern
Design Patterns
Design Patterns  Explain the Factory Pattern, VO Pattern, DAO Pattern, and Singleton Pattern
DESIGN PATTERNS
DESIGN PATTERNS  How many instances will be created for single ton pattern in Cluster Environment
Version of com.thesett>logic dependency
List of Version of com.thesett>logic dependency
how to design a parser - Design concepts & design patterns
how to design a parser  sorry i am not sure in which category i have to put my question actually i have to design a LR (0) parser for a given grammar in java i am confused how to implement this i know how the parser
struts logic tags
struts logic tags  what is the use of struts logic tag   The purpose of Struts logic tags is to alter output depending on the given...://www.roseindia.net/struts/struts-logictags/logic-tags-introduction.shtml http
web design
web design   Hii.. I have to design one registration page in java... SUGGESTIONs (here i have to design captcha) submit (while clicking... how could i design that. Please help me asap Thanks a lotADS_TO_REPLACE_2
Java - Design concepts & design patterns
Java  What are design patterens?  Hi friend, Software professionals may be familiar with the term "Design Patterns," but many have... not see the value and benefits design patterns bring to the software development
About Web-Logic
the Web-Logic with Tomcat 5.0 version in Console. Somebody has suggested to see the webpage (they had given the link).But when i installed the Web-Logic i... folder in the Web-Logic
Struts logic iterate
Struts logic iterate  This is my jsp page in which i used 3 logic...; <%@taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>...; <body> <h1> Search </h1> <logic:iterate name
Java - Design concepts & design patterns
Java  Sir , please let me know the exact usage of DAO design pattern  Hi Friend, Please visit the following link: http://www.roseindia.net/javatutorials/J2EE_singleton_pattern.shtml Thanks
logic for pattern program
logic for pattern program  what's the logic for create pattern program how can i create any pattern program with in minute. like this 123454321... create this program in java without help whats the logic how can i understand
jaavscript - Design concepts & design patterns
me the design code,how to design ,i will be grateful to you.Regards debasis
design software
design software  hello sir sir you asked me datial of software which i want to make. sir i want to make account software. and also i want to make graphics not command based. please you guide me how i will make
logic iterate tag - Struts
logic iterate tag  Hey I am displaying the values in a jsp called categoryView.jsp using logic iterate tag as Now properties bname and quant belongs to another formbean named as ViewCategoryForm.java.When I
Business Logic in mvc2 - JSP-Servlet
Business Logic in mvc2  What is business logic and where it is written using servlet and jsp
java - Design concepts & design patterns
java  Q What is the disadvantage of Singleton design pattern?  Hi Friend, 1)It allows only one instance of the class. 2)If the Singleton has synchronized blocks in it, it might slow the system down as the threads
For reqirment - Design concepts & design patterns
For reqirment  I have to design loyalty card system which is related with Point of sale. Please send some document related to loyalty card. I have no idea related to this so please help me to resolve this problem as soon
Javascript - Design concepts & design patterns
Javascript  Dear Sir, how to attach file while sending some files in a mail service??i have a button called attach files.After clickin that button what is the function to be called.Please give me some design code
logic for c language
logic for c language  01 02 03 04 05 06 20 21 22 23 24 07 19 32 33 34 25 08 18 31 36 35 26 09 17 30 29 28 27 10 16 15 14 13 12 11
Tell us the logic of diceroller
Tell us the logic of diceroller  import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public class DiceRollerServlet extends... is " +dice2); } } dice1 =3 dice2 =2 How is the logic executed????   
java - Design concepts & design patterns
java  design a vehicle class hierarchy in java.write a test program to demonstrate polymorphism.  Hi Friend, Try the following code: class Vehicle { void test(){} } class Bus extends Vehicle{ void test
java - Design concepts & design patterns
java  what is singleton design pattern?Give implementation of singleton design pattern? what is factory design pattern?and give its implementation.   Hi friend, class Singleton{ public static void main
Database Design
Database Design To design the database you first need to install the MySql database. The After create the database as create database if not exists `onlinexamination`; Then create the table new_ques which contains the queshon
Sugget a design pattern and the advantages in it - Design concepts & design patterns
Sugget a design pattern and the advantages in it  What is design pattern and what is the advantage of it?  Hi, using design pattern... of Design Pattern, i guess it's useful.http://www.javajazzup.com/issue9/page36.shtml
Please explain the logic....
Please explain the logic....  class A1 { } class B extends A1 { } public class ComingThru { static String s = "-"; public static void main(String[] args) { A1[] aa = new A1[2]; B[] ba = new B[2
ModuleNotFoundError: No module named 'logic-circuit-dave22153'
ModuleNotFoundError: No module named 'logic-circuit-dave22153'  Hi...: No module named 'logic-circuit-dave22153' How to remove the ModuleNotFoundError: No module named 'logic-circuit-dave22153' error? Thanks   
ModuleNotFoundError: No module named 'logic-toolchain'
ModuleNotFoundError: No module named 'logic-toolchain'  Hi, My... named 'logic-toolchain' How to remove the ModuleNotFoundError: No module named 'logic-toolchain' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pyapi-logic'
ModuleNotFoundError: No module named 'pyapi-logic'  Hi, My Python... 'pyapi-logic' How to remove the ModuleNotFoundError: No module named 'pyapi-logic' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'tarrah-logic'
ModuleNotFoundError: No module named 'tarrah-logic'  Hi, My Python... 'tarrah-logic' How to remove the ModuleNotFoundError: No module named 'tarrah-logic' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'tarrah-logic'
ModuleNotFoundError: No module named 'tarrah-logic'  Hi, My Python... 'tarrah-logic' How to remove the ModuleNotFoundError: No module named 'tarrah-logic' error? Thanks   Hi, In your python

Ads