Assignment #59

Code

  /// Name: Sam Wilson
  /// Period: 6
  /// Program Name: addingvalues
  /// File Name: addingvalues.java
  /// Date Finished: 12/19/2015

  import java.util.Scanner;
    
    public class addingvalues
    {
        public static void main(String[] args)
        {
            
           
            Scanner key = new Scanner(System.in);

            
            int i, c;
            c = 0;
            
            
            
            System.out.println("I will add up the numbers you give me until you give me 0");
            System.out.print("Number: ");
            i = key.nextInt(); 
            
             
            while (i != 0)
            {
               c = c + i;
                System.out.println("So far your total is: "+c);
                System.out.print("Number: ");
                
                i = key.nextInt();
                                   
            }
            
            System.out.println("Your Total is "+c);
            
        }
    }
    

Picture of the output

Assignment 31