Assignemnt 67 and Adding Values In a Loop

Code

    /// Name: Xinting Chen
    /// Period: 7
    /// Program Name: Adding Values In a Loop
    /// File Name: AddingValuesInLoop.java
    /// Date Finished: 12/9/2015
  
    
import java.util.Scanner;
import java.util.InputMismatchException;
import java.util.Random;

public class AddingValuesInLoop
{
	public static void main(String[] args)
	{
		Scanner keyboard = new Scanner(System.in);

		int number, total;
        total= 0;
        
        System.out.println( "I will add up the numbers you give me." );
            System.out.print( "Number: ");
            number = keyboard.nextInt();
            
            while ( number!= 0 )
            {
                total = total + number;
                System.out.println( "The total so far is " + total );
                System.out.print( "Number: ");
                number = keyboard.nextInt();
            }
            
            System.out.println( "The total is " + total );
        }
    }



    

Picture of the output

Assignment 67