-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLessonFour.java
More file actions
51 lines (34 loc) · 1019 Bytes
/
LessonFour.java
File metadata and controls
51 lines (34 loc) · 1019 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package Lesson04;
import logic.Lesson;
import java.util.Scanner;
public class LessonFour extends Lesson {
@Override
public void theLesson() {
Scanner input = new Scanner(System.in);
int total = 0, numInput = 0;
System.out.println("We are now adding numbers starting at 0:");
while (numInput != -1) {
total += numInput;
numInput = input.nextInt();
}
System.out.printf("Your total is: %d", total);
System.out.println("/n We are now subtacting numbers starting at your total:");
for (numInput = 0; numInput != -1; numInput = input.nextInt()) {
total -= numInput;
}
int i = 0;
while (i < 6) {
//This is where you would do stuff!
i++;
}
//We could have also reused i in this for loop but I wanted to show you that you can also create variables within it.
// for (i = 0; i < 6; i++) is how you could reuse your variable.
for (int j = 0; j < 6; j++) {
//This is where you would do stuff!
}
input.close();
}
@Override
public void theAssignment() {
}
}