Assignment #67

Code

    ///Name: Cody Swain
    ///Period: 6
    ///Project Name: ValuesInALoop
    ///File Name: ValuesInALoop.java
    ///Date: 12/4/15
    
    import java.util.Scanner;
    import java.util.Random;
    
    public class ValuesInALoop
    {
        public static void main( String[] args )
        {
            Scanner keyboard = new Scanner(System.in);
            Random r = new Random();
            int n, sum;
            sum = 0;
             
            System.out.println( "I will add up the numbers you give me. ");
            System.out.print( "Number: ");
            n = keyboard.nextInt();
            
            
            while ( n != 0 )
            {
                sum = n + sum;
                System.out.println("The total so far is " + sum );
                System.out.print( "Number: ");
                n = keyboard.nextInt();
            }
            if ( n == 0 )
                System.out.println( "Your  total is " + sum );
    
        }
    }
        
            
            
            

        
    

Picture of the output

Assignment 67