Assignment # 67 and Adding Values in a Loop

Code

    /// Name: Tommy Oyuntseren
    /// Period: 7
    /// Program Name: Adding
    /// File Name: Adding.java
    /// Date: 1/11/2016

import java.util.Scanner;
import java.util.Random;

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

		int num = 0;
		int total = 0;
		System.out.print("I will add the numbers you give me.\n");
		{
			do
			{
				System.out.print("Number: ");
				num = keyboard.nextInt();

				total += num;
				System.out.println();
				if (num != 0) System.out.println("The total so far is "+total+".");
				else System.out.println("The total is "+total+".");
				System.out.println();
			}
			while (num!=0);
		}
		System.out.println();
	}
}


  

Picture of the output

Assignment 67