Question: Create a Java program named PrintBioScanner.java that : prompts a user for first name, last name, DOB, and major using a Java Scanner object. prints
Create a Java program named PrintBioScanner.java that :
prompts a user for first name, last name, DOB, and major using a Java Scanner object.
prints the input values to look similar to the following run:
Enter first name: Alan Enter last name: Turing Enter DOB: 06/23/1912 Enter major: Mathematics First name: Alan Last name: Turing DOB: 06/23/1912 Major: Mathematics
How would I cod this?
My code is below and it doesn't show up like what is above. I have the names lined up, but it prints out everything. I am using visual studio code. Thanks
import java.util.Scanner;
public class PrintBioScanner {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.print("Enter first name:");
String first = sc.nextLine();
System.out.print("Enter last name: ");
String last = sc.nextLine();
System.out.print("Enter DOB: ");
String date = sc.nextLine();
System.out.print("Enter major: ");
String major = sc.nextLine();
System.out.println("First name:" + "\t" + first);
System.out.println("Last name:" + "\t" + last);
System.out.println("Last name:" + "\t" + date);
System.out.println("Last name:" + "\t" + major);
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
