Assignment #67: Adding Values in a Loop

Code

/// Name: Kiran O'Farrell
/// Program Name: Adding in a Loop
/// File Name: LoopAdder
/// Date Completed: 1/20/16

import java.util.Scanner;

public class LoopAdder { 

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

Picture of the output