Assignment #67 and Adding Values in a Loop
Code
//Name: Mark Katz
///Period: 6
///Program Name: Adding Values in a Loop
///File Name: add.java
///Date Finished: 10/28/15
import java.util.Scanner;
public class add
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int num,count;
count=0;
System.out.println( "I will add up the numbers you give me." );
System.out.print( "Number: ");
num = keyboard.nextInt();
while ( num!= 0 )
{
count = count + num;
System.out.println( "My total so far is " + count );
System.out.print( "Number: ");
num = keyboard.nextInt();
}
System.out.println( "The total is " + count );
}
}
Picture of the output