Assignemnt #67 and Adding Values in a Loop
Code
///Name: Luke Shin
///Period: 7
///Project Name: AddWithLoop
///File Name: AddWithLoop.java
///Date: 12/14/2015
import java.util.Scanner;
import java.util.Random;
public class AddWithLoop{
public static void main(String[] args){
Scanner keyboard = new Scanner(System.in);
int a = 0, end = 0;
System.out.println("I will add up the numbers you give me. If you are done, put \"0\" for the number");
do {
System.out.print("Nubmer: ");
a = keyboard.nextInt();
end += a;
System.out.println();
if ( a != 0) System.out.println("The total so far is "+ end + ".");
else System.out.println("The total is " + end + ".");
}
while (a != 0);
}
}
Picture of the output