I have to get output like below.
name: Hershey, Joe
Birthday: 09 / 05 / 79
But , my final output is only Joe.
what’s wrong with my input?
Show transcribed image textFor this program, you will need to prompt the user to input his/her first name, last name, birth month, birth day and birth year. Then you will display this information in two lines with the appropriate labels. Example Input (this is the line of output from the program) Please enter your first name: Joe (this is what the user will enter) Please enter your last name Schmoe Please enter your birth month: 12 Please enter your birth day; Please enter your birth year 90 Example output: Name: Schmoe, Joe Birthday: 12/1/90 Internal documentation includes: a. Name b. Date c. Class d. Program Purpose what does this program do e. Single line documentation of any unique line(s) of programming
Expert Answer
import java.util.Scanner;
class User_Detail1{
public static void main(String []args){
Scanner sc = new Scanner(System.in);
System.out.println(“Please enter your First name”);
String fName = sc.next();
System.out.println(“Please enter your Last name”);
String lName = sc.next();
System.out.println(“Please enter your Birth Month”);
int birthM = sc.nextInt();
System.out.println(“Please enter your Birth Day”);
int birthD = sc.nextInt();
System.out.println(“Please enter your Birth Year”);
int birthY = sc.nextInt();
System.out.println(“Name: ” + lName + “,” + fName);
System.out.println(“Birthday: ” + birthM + “/” + birthD + “/” + birthY);
}
}
Please note: You were not getting the required output as you were hard coding the values of fName, lName, bithM, birthD and birthY.