26 lines
726 B
Java
26 lines
726 B
Java
/*
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
|
*/
|
|
package lab11_calebfontenot;
|
|
|
|
import java.util.Scanner;
|
|
|
|
/**
|
|
*
|
|
* @author caleb
|
|
*/
|
|
public class DoWhileEvent1 {
|
|
public static void main(String[] args) {
|
|
Scanner scan = new Scanner(System.in);
|
|
int num = 0;
|
|
int sum = 0;
|
|
do {
|
|
System.out.print("Please enter a positive number to add it to the sum or -1 to quit: ");
|
|
num = scan.nextInt();
|
|
sum = num != -1 ? sum + num : sum;
|
|
} while (num != -1);
|
|
System.out.println("Total : " + sum);
|
|
}
|
|
}
|