Help, I cannot work out how to get my loop to continue until the user enters in 0.
If the user enters 1 then the loop needs to continue until there is no more groups to enter which is the point the user enters a 0
import java.util.Scanner;
public class ZooEntryCharge {
public static void main(String[] args) {
//assign value
int GroupValue = 0;
// Create a scanner
Scanner input = new Scanner(System.in);
do {
// prompt for user input
System.out.print("Enter a group y = 1 or n = 0 ");
int intGroupValue = input.nextInt();
System.out.print("Enter number of children age under 5 ");
int intUnderFiveValue = input.nextInt();
System.out.print("Enter the number of children accompanied by an adult aged from 6 to 15 years old ");
int intAccompaniedChildValue = input.nextInt();
System.out.print("Enter the number of unaccompanied by an adult aged from 6 to 15 years old ");
int intUnaccompaniedChildValue = input.nextInt();
System.out.print("Enter the number of adults from 16 to 59 years old ");
int intAdultValue = input.nextInt();
System.out.print("Enter the number of seniors aged 60 and older ");
int intSeniorsValue = input.nextInt();
// reads value and prints out
int Value = intUnderFiveValue + intAccompaniedChildValue + intUnaccompaniedChildValue + intAdultValue + intSeniorsValue;
System.out.println ("Total amount of people in the group is " + Value );
// end loop if group value is not 1
}while (GroupValue != 0);
total = Value + Value;
System.out.println("The total number of groups is " + total);
}
}
Thank-you for your help