Assignemnt #67 Values In A Loop
Code
/// Name: Jake Johnson
/// Period: 7
/// Program Name: ValuesInALoop
/// File Name: ValuesInALoop.java
/// Date Finished: 12/8/2015
import java.util.Scanner;
public class ValuesInALoop
{
public static void main (String [] args)
{
Scanner keyboard = new Scanner(System.in);
int number = 0;
int number2 = 1;
System.out.println("I will add up the numbers you give me");
System.out.print("Number: ");
number = keyboard.nextInt();
while(number2 != 0)
{
System.out.println("The total is " + number);
System.out.print("Number: ");
number2 = keyboard.nextInt();
number = (number + number2);
}
System.out.println("\nThe total is " + number);
}
}
Picture of the output