I'm working on an assignment for my Java class and I keep getting compiler errors.
The errors I'm getting are "not a statement subtotal ++ total;" and "error: ';' expected subtotal ++ total;".
Any advice would be greatly appreciated.
The assignment is to create a program that adds numbers together and prints the subtotal once the user enters a zero, and prints the complete total after two consecutive zeros.
I am using this website for the programming and compiling: http://www.compileonline.com/compile_java_online.php
Thanks in advance.
public class Homework4{
public static void main(String []args){
int n;
int previous = -99999;
int total = 0;
int subtotal = 0;
System.out.println("This program will add numbers you input.");
System.out.println("Once you input a number, press enter.");
System.out.println("When you want the subtotal of your numbers, input 0.");
System.out.println("When you want the complete total, input 0 once more.");
n = scanner.nextInt ( );
while (true) {
if (n == 0 && previous == 0) {
System.out.println("Total: " + total);
} else if (n == 0) {
subtotal ++ total;
System.out.println("Subtotal: " +subtotal);
subtotal == 0;
previous == 0;
} else {
n ++ subtotal;
previous == n;
}
n = scanner.nextInt ( );
}
}
}