This question already has an answer here:
- Getting User input with Scanner 4 answers
I need help creating a input field within the console for my java code, I can't seem to find a way to ask a user to input their age and weight. Here is my code so far everything works without error when I change the age and weight. I also need it to ask to enter the weight in lbs.
public class rollerCoaster {
public static void main(String[] args) {
int age = 8;
int weight = 181;
if ( age <= 10 && weight < 10 ) {
System.out.println("This person needs to ride the black roller coaster.");
}
else if ( age <= 10 && weight >= 80 && weight <= 200) {
System.out.println("This person needs to ride the green roller coaster.");
}
else if (age >= 10 && weight > 200) {
System.out.println("This person needs to ride the yellow roller coaster.");
}
else if (age > 10 && age <= 20 && weight < 10) {
System.out.println("This person needs to ride the silver roller coaster.");
}
else if (age > 10 && age <= 20 && weight >= 80 && weight <= 200) {
System.out.println("This person needs to ride the red roller coaster.");
}
else if (age > 10 && age <= 20 && weight > 200) {
System.out.println("This person needs to ride the purple roller coaster.");
}
else {
System.out.println("This person needs to ride the pink roller coaster.");
};
}; };
Aucun commentaire:
Enregistrer un commentaire