Write a method called inputBirthday
that accepts a Scanner for the console as a parameter and prompts the user to enter a month, day, and year of birth, then prints the birthdate in a suitable format. Here is an example dialogue with the user:
On what day of the month were you born? 8
What is the name of the month in which you were born? May
During what year were you born? 1981
You were born on May 8, 1981. You're mighty old!
So this is what I have done:
import java.util.Scanner;
public static void inputBirthday(int month,String day,int year){
Scanner sc=new Scanner(System.in);
System.out.print("On what day of the month were you born?");
month=sc.nextInt();
System.out.print("What is the name of the month in which you were born?");
day=sc.nextLine();
System.out.print("During what year were you born?");
year=sc.nextInt();
}
My code failed to compile. Can someone give me some hints and I will try it out on my own.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…