public static void add2q(){
System.out.print("Age:");
age = sc.nextInt();
if(!(age>=3 && age <=80)){
System.out.println("Sorry you must be between the age of 3 to 80");
}else if(age>=3 && age<=5){
while(true){
System.out.println("Need to be accompanied by an adult above 16\nHave an adult to accompany?y/n");
String yn = sc.nextLine();
if(yn.equals("y")){
System.out.print("Child's Name: ");
name = sc.nextLine();
names.add(name);
price();
addAdult();
break;
}else if(yn.equals("n")){
while(true){
System.out.println("Sorry you cannot take this ride");
add2q();
break;
}
}else{
System.out.println("Invalid output");//funny problem here
}
}
}else{
System.out.print("Name: ");
name = sc.nextLine();
names.add(name);
price();
}
}
//'When user types in 3 or 4 or 5, it will print the "need to be..." and the //"Invalid output statement"(i dont want this statement).'
Aucun commentaire:
Enregistrer un commentaire