Assignemnt #68
Code
/// Name: Daniel Nguyen
/// Period: 6
/// Program Name: loopval Program
/// File Name: loopval.java
/// Date Finished: 9/9/2015
import java.util.Scanner;
public class loopval
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int num, total;
num = 1;
total = 0;
System.out.println("I will add up all the numbers you give me until you give me a 0");
while ( num != 0 ) {
System.out.print("Number: ");
num = keyboard.nextInt();
total = num + total;
System.out.println("The total currently is " + total);
}
System.out.println("Your final total is " + total);
}
}
Picture of the output