×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
Write a programme to accept a word and display the alphabets in an alphabetical order. Write a program to Blinking a Text using Applet.
Write a programme in java to accept a month name and print the month number. - Java
9492    Arnab De    12/06/2018

Write a programme in java to accept a month name and print the month number.

Create a string array by populating the month name. Now accept the month name from user and match it to the array. If match it then print the (index+1) as a month number.

softetechnologies
public class MonthNameToNumber
{
    public static void main(String []args)
    {
        String []months={"January","Februry","March","April","May","June","July","August","September","October","November","December"};
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter month name : ");
        String mon=sc.next();
        for(int i=0;i<months.length;i++)
        {
            if(mon.toLowerCase().equals(months[i].toLowerCase()))
            {
                System.out.println("Your Month number is " + (i+1));
                break;
            }
        }
    }
}
softetechnologies

Output

Enter month name : january
Your Month number is 1
Enter month name : May
Your Month number is 5

Write a programme to accept a word and display the alphabets in an alphabetical order. Write a program to Blinking a Text using Applet.
softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Mahatma Gandhi
By education, I mean all-around drawing of the best in child and man in body, mind and sprit.
Mahatma Gandhi
16198
52.48
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     41979
01/01/2018     35991
28/06/2017     34082
25/06/2018     33432
02/08/2017     32394
01/08/2017     26807
06/07/2017     26785
15/05/2017     26415
14/07/2017     21851
21/04/2018     20711
softetechnologies