Assignemnt #67
Code
/// Name: Ryan Volko
/// Period: 7
/// Program Name: ValuesLoop
/// File Name: ValuesLoop.java
/// Date Finished: 12/14/2015
import java.util.Random;
import java.util.Scanner;
public class ValuesLoop
{
public static void main( String[] args )
{
int x, t;
Random r = new Random();
Scanner keyboard = new Scanner(System.in);
t = 0;
System.out.println(" What is your starting number");
System.out.print("> ");
x = keyboard.nextInt();
System.out.println("");
while ( x !=0)
{
t = t + x;
System.out.println("The total is " + t);
System.out.print("Your new number: ");
x = keyboard.nextInt();
System.out.println("");
}
System.out.println("Your total is " + t);
}
}
Picture of the output