-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEverySum.java
More file actions
39 lines (29 loc) · 1.07 KB
/
Copy pathEverySum.java
File metadata and controls
39 lines (29 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Writen by Edgar Colin
// Aug 22th 2016
// Class: CIS163 Java I
// Prof: Michael Parmeley
// Section 14887
// HW 6 Problem 6 Modified
// Filename: EverySum.java
import java.util.Scanner;
public class EverySum
{
public static void main(String[] args)
{
System.out.println("The Following Program Outputs the calculation for" +
"the sum of the nth\nnumbers from n = 1 to n = 50. The left hand side" +
"displayes the nth number \nand the right side displays the sum of all the natural" +
"numbers preceding \nthat nth number (i.e nth SUM = [n + (n-1) + (n-2) +... + 2 + 1]).");
System.out.println(" ------------------");
System.out.println(" Adding Nth Numbers");
System.out.println(" _____________");
System.out.println(" | Nth | SUM |");
System.out.println(" _____________");
int sum = 0;
for( int x = 1; x <= 50 ; x ++)
{
sum = sum + x;
System.out.println( " * " + x + " SUM = " + sum + " *" );
}
}
}