-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathMain.java
More file actions
44 lines (35 loc) · 1.16 KB
/
Main.java
File metadata and controls
44 lines (35 loc) · 1.16 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
40
41
42
43
44
/**
* Created by iyasuwatts on 10/17/17.
* Modified by kristofer in Jan 2024
*/
public class Main {
public static void main(String[] args) {
int number = getInputNumber();
int sum = sumOfNumbers(number);
System.out.println(sum);
}
// do this one and the lab is complete. really.
// return the sum of 0 to n... if n == 3, the result should be 6
int sumOfNumbers(int n) {
return 0;
}
boolean testSumOfNumbers() {
return sumOfNumbers(3) == 6; // 3 + 2 + 1 + 0 = 6
}
int getInputNumber() { // gee, may thi sis useful in another lab?
Scanner scan = new Scanner(System.in);
System.out.print("Enter any number: ");
// This method reads the number provided using keyboard
int num = scan.nextInt();
// Closing Scanner after the use
scan.close();
return num;
}
// for Extra Credit
int gaussianSumOfNumbers(int n) {
return 0;
}
// for Extra extra credit - compare the methods and show which one is faster
// google "how to time some java code"
// use "System.currentTimeMillis()" to ask the system what time it is.
}