Hi there. This is actually one of my assignment and i am having problem with the do while sentinel looping. The result i get is totally inverse from the one i expected. The system is supposingly ended when user enter 0, but it ended when user enter any value but the looping continue when user enter 0.
These are the code. Thank you.Sorry i am still very new in programming. =(
import java.util.Scanner;
public class SoftwareWorkshop {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int Registrant, totalRegistrant;
double Charges, totalCharges, averageCharges, totalAll;
totalRegistrant = 0;
totalAll = 0;
Registrant =0;
do {
System.out.println("Enter amount of registrant in the company.Enter 0 to end the system.");
Registrant = input.nextInt();
if (Registrant >=11) {
Charges = 250;
totalCharges = (Registrant * Charges);
totalRegistrant += Registrant;
totalAll += totalCharges;
System.out.println("The total is RM" + totalCharges);
}
else if (Registrant >= 6) {
Charges = 400;
totalCharges = (Registrant * Charges);
totalRegistrant += Registrant;
totalAll += totalCharges;
System.out.println("The total is RM" + totalCharges);
}
else {
Charges = 450;
totalCharges = (Registrant * Charges);
totalRegistrant += Registrant;
totalAll += totalCharges;
System.out.println("The total is RM" + totalCharges);
}
}
while(Registrant == 0); {
System.out.println("End");
}
}
}