Assignment #67 and AddingValuesLoop
Code
/// Name: Jason Kim
/// Period: 7
/// Program Name: AddingValuesLoop
/// File Name: AddingValuesLoop.java
/// Date Finished:11/9/15
import java.util.Scanner;
public class AddingValuesLoop
{
public static void main(String[]args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("I will add up the numbers you give me.");
System.out.print("Number: ");
int number = keyboard.nextInt();
int total = number;
while (number !=0)
{
System.out.println("Your total so far is " + total );
System.out.print("Number: ");
number = keyboard.nextInt();
total = total + number;
}
System.out.println("\nThe total is " + total + ".");
}
}
Picture of the output