Код: Выделить всё
public static void main(String[] args){
Scanner sc = new Scanner(System.in); //create scanner object
//code prompts user for group
System.out.println("Enter a group? (Yes = 1/No = 0): ");
int group = sc.nextInt();
int children = sc.nextInt();
int adults = sc.nextInt();
int seniors = sc.nextInt();
//if user enters 1, the following code should execute, prompting for numbers, then give an entry
// charge
while (group == 1) {
System.out.println("Enter the number of children (age 6 - 15): "+children);
System.out.println("Enter the number of adults (16 - 59): "+adults);
System.out.println("Enter the number of seniors (age 60+) "+seniors);
System.out.println("Total entry charge is $");//needs to include calculation
}
System.out.println("Total takings: $")//needs to include sum calculation of all charges in while
//loop
}
[img]https:/ /i.sstatic.net/MBQryQdp.png[/img]
Подробнее здесь: https://stackoverflow.com/questions/788 ... while-loop
Мобильная версия