Question #3549

Write a program to take your date of birth as input i.e. int date, int month, int
year. Take all the inputs from the scanner and print all those inputs as date of
birth format.

Expert's answer

import java.util.Scanner;




public class Main {




public static void main(String[] args) {

int day, month, year;

String m = null;

Scanner in = new Scanner(System.in);

System.out.print("Enter day: ");

day = in.nextInt();

System.out.print("Enter month: ");

month = in.nextInt();

System.out.print("Enter year: ");

year = in.nextInt();

switch(month){

case 1: m = "January";

case 2: m = "February";

case 3: m = "March";

case 4: m = "April";

case 5: m = "May";

case 6: m = "June";

case 7: m = "July";

case 8: m = "August";

case 9: m = "September";

case 10: m = "October";

case 11: m = "November";

case 12: m = "December";




}

System.out.println(m + " " + day + ", " + year + ".");

}

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS