Assignment #88 and Adding Values
Code
/// Name: Graham Pollock
/// Period: 5
/// Program Name: Adding Values
/// File Name: AddingValues.java
/// Date Finished: 02/27/2016/
import java.util.Scanner;
public class AddingValues
{
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
int input, total;
total = 0;
System.out.print("Number: ");
input = kb.nextInt();
for (int n = 1; n <= input; n++)
{
System.out.print(n + " ");
total = total + n;
}
System.out.println("");
System.out.println("the sum is " + total);
}
}
Picture of the output