Assignemnt #67 and Adding Values in a Loop

Code

    /// Name: Brian Phillips
    /// Period: 5
    /// Program name: AddingInLoop.java
    /// File Name: Adding Values In a Loop
    /// Date Finished: 1/4/2015
import java.util.Scanner; 

 public class AddingInLoop
 {
        public static void main(String[] args)
        {
            Scanner keyboard = new Scanner(System.in);
            
            System.out.println("I will add up the numbers you give me. ");
            int entry = keyboard.nextInt();
            
            int total = entry;
            while ( entry != 0 )
    		{
			System.out.println("The total so far is " + total + ".");
			System.out.print("Number: ");
			entry = keyboard.nextInt();
            total = entry + total;
		    }
    		if ( entry == 0 )
    		{
    			System.out.println( "The total is " + total + ".");
    		}
            
        }
    }
    

Picture of the output

AddingInLoop.html