Prog 67: Adding Values in a Loop
///Name: Ilana Levy
///Period: 5
///Program Name: Adding Values in a Loop
///File Name: addingLoop.java
///Date Finished: 9/21/2015
import java.util.Scanner;
public class addingLoop
{
public static void main( String[] args )
{
Scanner keyboard = new Scanner( System.in );
int number, total = 0;
System.out.print( "I will add up the numbers you give me.\nNumber: " );
number = keyboard.nextInt();
System.out.print( "The total so far is " + number );
while ( number != 0 )
{
System.out.print( "Number: " );
number = keyboard.nextInt();
total = total + number;
System.out.println( "The total so far is " + total );
}
}
}