Assignemnt #67 Adding Variables in a Loop
Code
///Name: Morgan Kaplan
///Period: 5
///Project Name: Adding Variables In A Loop
///File Name: AVIAL.java
import java.util.Scanner;
public class AVIAL
{
public static void main( String[] args)
{
Scanner momo= new Scanner(System.in);
int Number, sum=0;
System.out.println( "I will add up the numbers you give me.");
System.out.println( " Number: " );
Number=momo.nextInt();
while ( Number!=0 )
{
sum= sum + Number;
System.out.println(" Your total is " + sum + " ");
System.out.println( " Number: " );
Number=momo.nextInt();
}
}
}
Picture of Output