Assignemnt #88 Adding Values With a For Loop
Code
///Name: Morgan Kaplan
///Period: 5
///Project Name: Adding Values With a For Loop
///File Name: AVWAFL.java
import java.util.Scanner;
public class AVWAFL
{
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();
for ( int n=1; n<=Number; n=n+1)
{
System.out.println(""+n+"");
sum=sum+ n;
}
System.out.println("Your sum is " + sum + "");
}
}
Picture of Output