1)Your program will get numbers (int) from the user. Do this in a while loop so that you keep getting more numbers.
If the number is a multiple of 3 or 5, do nothing (use the "continue" command for this)
If the number is -99 then exit the loop
All other numbers should be added to the total (yes, you're making a total of all of the numbers)
After you exit the while loop print out the total
my code
package postMarchBreak;
import java.util.Scanner;
public class While99 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("pick a few numbers and type -99 to stop");
while (true){
int num = sc.nextInt();
int sum = 0;
if (num==-99)
break;
if(num%3 == 0 || num%5 == 0){
continue;
}
sc.close();
}
}
}
how can I add up all the numbers that aren't multiples of 3 or 5
3 answers
continue;
} else {
sum += num
}
At the end of the loop, just print the value of sum.