Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Word Game Write a program that plays a word game with the user. The program shou

ID: 669125 • Letter: W

Question

 Word Game Write a program that plays a word game with the user. The program should ask the user to enter the following: • His or her name • His or her age • The name of a city • The name of a college • A profession • A type of animal • A pet’s name After the user has entered these items, the program should display the following story, inserting the user’s input into the appropriate locations: There once was a person named NAME who lived in CITY. At the age of AGE, NAME went to college at COLLEGE. NAME graduated and went to work as a PROFESSION. Then, NAME adopted a( n) ANIMAL named PETNAME. They both lived happily ever after! 

Explanation / Answer

import java.util.*;
public class HelloWorld{

public static void main(String []args){
Scanner s=new Scanner(System.in);
System.out.print("Enter your name: ");
String name=s.next();
System.out.print("Enter name of your city: ");
String city=s.next();
System.out.print("Enter your age: ");
String age=s.next();
System.out.print("Enter name of your college: ");
String college=s.next();
System.out.print("Enter your profession: ");
String profession=s.next();
System.out.print("what animal do you have as pet?: ");
String animal=s.next();
System.out.print("Enter name of your pet: ");
String pet=s.next();
System.out.print("There once was a person named "+name+" who lived in "+city+".");
System.out.print("At the age of "+age+", "+name+" went to college at "+college+".");
System.out.print(name+" graduated and went to work as a "+profession+".");
System.out.print("Then, "+name+" adopted an "+animal+" named "+pet+".");
System.out.print("They both lived ever after! ");

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote