0

So we have a story project for my software engineering class (Java). It asks the user's name, age , college, etc. The goal is to have a print with the information gathered from the user to tell a story.

`import java.util.; public class Febuary14 { / * • His or her name • His or her age • The name of a city • The name of a college • The name of 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!
 */
public static void main(String[] args) {
Scanner userin = new Scanner(System.in);

System.out.print("Please enter your name");
String name = userin.nextLine();

System.out.print("Please enter your age when you started college");
int age = userin.nextInt();
    
System.out.print("Please enter the city your from");
String city = userin.nextLine();

System.out.print("Please enter the college you attended");
String college = userin.nextLine();

System.out.print("Please enter your profession");
String job = userin.nextLine();

System.out.print("Please enter the type of pet you have");
String pet = userin.nextLine();

System.out.print("Please enter your pets name");
String petname = userin.nextLine();

System.out.printf("There was once a person named " + name + "who lived in " + city + ". " + "At the age of" + age + ", " + name + "went to college at " + college + "." );
System.out.printf(name + "graduated and went to work as a " + job + ". Then, " + name + "adopted a(n) " + pet + "named " + petname + ". They both lived happily ever after!");

}

} `

This is what was tried, and the result is after int age, string city & college get asked together when they shouldn't

0 Answers0