Assignment #67 Adding Values in a Loop
Code
/// Name: John Huh
/// Period: 6
/// Program Name: Adding Values in a Loop
/// File Name: AddValue.java
/// Date Finished: 12/16/2015
import java.util.Scanner;
public class AddValue
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner(System.in);
int addition, total;
total = 0;
System.out.println();
System.out.println( "I will add up the numbers you give me." );
System.out.print( "Number: " );
addition = keyboard.nextInt();
System.out.println();
while ( addition != 0 )
{
total = total + addition;
System.out.println( "The total so far is " + total + "." );
System.out.print( "Number: " );
addition = keyboard.nextInt();
}
System.out.println();
System.out.println( "The total is " + total + "." );
System.out.println();
}
}
Picture of the output