Assignment #67

Code

    /// Name: Jonathan Stine
    /// Period: 5
    /// Program Name: Adding Values in a Loop
    /// File Name: AddingValues.java
    /// Date Finished: 1/19/16
    
    import java.util.Scanner;
    
    public class AddingValues {
        
        public static void main( String[] args ) {
            
            Scanner keyboard = new Scanner(System.in);
            
            int total, entry;
            total = 0;
            entry = 1;
            
            System.out.println( "I will add up the numbers you give me." );
            
            while ( entry != 0 ) {
                System.out.print( "Number: " );
                entry = keyboard.nextInt();
                total = total + entry;
                
                if ( entry != 0 ) {
                System.out.println( "The total so far is " + total );
                }
            }
            
            System.out.println();
            System.out.println( "The total is " + total + "." );
            
        }
    }
    
    
 
    

Code Output