Assignment #X
Code
///jack newsom
///period 5
///program name Adding
///filename Adding
///date completed 10/8/15
import java.util.Scanner;
public class Adding
{
public static void main( String[] args )
{
Scanner bot = new Scanner(System.in);
System.out.println("I will add up the numbers you give me.");
System.out.println("Number: ");
int num = bot.nextInt();
int sum = num;
while ( num != 0 )
{
System.out.println("The total so far is " + sum + ".");
System.out.println("Number: ");
num = bot.nextInt();
sum = sum + num;
}
System.out.println();
System.out.println("The total is " + sum + ".");
}
}
Picture of the output