Assignment #67 and Adding Values in a while loop
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: Adding Values
/// File Name: addingV.java
/// Date Finished: 12/11/2015/
import java.util.Scanner;
public class addingV
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int number, total;
total=0;
System.out.println("I will add up the numbers you give me.");
System.out.print("Number: ");
number = keyboard.nextInt();
System.out.println("");
while (number != 0)
{
total = total + number;
System.out.println("The total so far is " + total );
System.out.print("Number: ");
number = keyboard.nextInt();
System.out.println("");
}
System.out.println("the total is " + total );
}
}
Picture of the output