/home/caleb/ASDV-Java/Assignments/lab11_CalebFontenot/src/lab11_calebfontenot/DoWhileEvent2.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package lab11_calebfontenot;
import java.util.Scanner;
public class DoWhileEvent2 {
public static void main(String[] args) {
System.out.println("Please enter a positive number to add it to sum or -1 to quit");
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
int sum = 0;
do
{
sum += num;
System.out.println("Please enter a positive number to add it to sum or -1 to quit");
num = scan.nextInt();
}
while (num != -1);
System.out.println("Total " + sum);
}
}