forked from Zipcoder/BlueJ.SumOfInput
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumOfInput.java
More file actions
31 lines (28 loc) · 696 Bytes
/
SumOfInput.java
File metadata and controls
31 lines (28 loc) · 696 Bytes
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
/**
* This class takes an interager value, then adds together all of the
* numbers, starting from one, up until it reaches the entered value.
* @author (Jacob Stagg)
* @version (10-29-21)
*/
public class SumOfInput
{
// instance variables - replace the example below with your own
private Integer sum;
/**
* Constructor for objects of class SumOfInput
*/
public SumOfInput()
{
// initialise instance variables
sum = 0;
}
public Integer oneToNumber(Integer numberToSum)
{
sum = 0;
for (int i = 1; i <= numberToSum; i++) {
sum += i;
}
System.out.println(sum);
return sum;
}
}