The program should ask the user to enter (use the Scannerclass) the following: -
ID: 3608628 • Letter: T
Question
The program should ask the user to enter (use the Scannerclass)the following:
- His or her first name
- His or her middle name
- His or her last name
- His or her age
- His or her lucky number
- His or her favorite color
If the user's name was Not Too Young,
the output of the program should be as follows.
% java Assignment2
A story about Not Too Young:
NOT TOO YOUNG is NTY.
NTY's favorite coloris red, and Not Y. is23.
The lucky number of N. T. Young is 77.
Actually, I really do not know how to get those.......? it should be from our first, middle, and last nameinput..... but I do not know how..... could you help me out!!!??
The program should ask the user to enter (use the Scannerclass)
the following:
- His or her first name
- His or her middle name
- His or her last name
- His or her age
- His or her lucky number
- His or her favorite color
If the user's name was Not Too Young,
the output of the program should be as follows.
% java Assignment2
A story about Not Too Young:
NOT TOO YOUNG is NTY.
NTY's favorite coloris red, and Not Y. is23.
The lucky number of N. T. Young is 77.
Actually, I really do not know how to get those.......? it should be from our first, middle, and last nameinput..... but I do not know how..... could you help me out!!!??
Explanation / Answer
import java.util.Scanner;public class Test{public static void main(String[] args) {String fn,mn,ln,lucky_num,fav_color,str;int age;Scanner keyboard = new Scanner(System.in);System.out.println("Enter first name ");str = keyboard.next();fn=str;System.out.println("Enter middle name ");str = keyboard.next();mn=str;System.out.println("Enter last name ");str = keyboard.next();ln=str;System.out.println("Enter age ");age= keyboard.nextInt();System.out.println("Enter lucky num ");str = keyboard.next();lucky_num = str;System.out.println("Enter fav color ");str = keyboard.next();fav_color=str;if(age > 13 ){ System.out.println("NOT TOO YOUNG is " + fn.charAt(0) + mn.charAt(0) + ln.charAt(0));System.out.println(fn.charAt(0) + mn.charAt(0) + ln.charAt(0)+"'s favorite color is "+ fav_color+ ", and Not "+ ln.charAt(0)+" is "+age+".");System.out.println("The lucky number of " + fn.charAt(0) + mn.charAt(0) + ln.charAt(0) + "'s is " + lucky_num + " Young is " +age);}elseSystem.out.println("TOO YOUNG is " +fn.charAt(0) + mn.charAt(0));}}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.