-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyFirstApp.java
More file actions
67 lines (46 loc) · 2.57 KB
/
Copy pathMyFirstApp.java
File metadata and controls
67 lines (46 loc) · 2.57 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
public class MyFirstApp {
public static void main(String[] args) {
// ---------------------------------------------------------------
// TASK 1: Variable Declarations and Assignments (25 pts)
// ---------------------------------------------------------------
// TODO: Declare an int variable named x and set it equal to 3
// TODO: Declare a String variable named name and set it equal to "Dirk"
// TODO: Multiply x by 17 and store the result back in x
// TODO: Print "x is " followed by the value of x using System.out.print()
// TODO: Declare a double variable named d and assign it a random number
// using Math.random()
// TODO: Add a single-line comment (starting with //) explaining one of the
// lines above
// ---------------------------------------------------------------
// TASK 2: Loops (30 pts)
// ---------------------------------------------------------------
// TODO: Write a while loop that subtracts 1 from x as long as x is
// greater than 12
// TODO: Write a for loop that:
// - Starts i at 0
// - Continues while i is less than 10
// - Increments i by 1 each time
// Inside the loop, print "i is now " followed by the value of i,
// each on its own line
// ---------------------------------------------------------------
// TASK 3: Conditional Branching (30 pts)
// ---------------------------------------------------------------
// TODO: Write an if/else statement:
// - If x equals 10, print "x must be 10"
// - Otherwise, print "x isn't 10"
// TODO: Write an if statement that prints "Gently" if BOTH of these
// are true:
// - x is less than 3
// - name equals "Dirk" (use .equals() to compare Strings!)
// TODO: Print "this line runs no matter what" (this should be OUTSIDE
// any if/else block so it always executes)
// ---------------------------------------------------------------
// TASK 4: Syntax Rules (15 pts)
// ---------------------------------------------------------------
// Before you submit, verify:
// [ ] Every statement ends with a semicolon
// [ ] All opening { have a matching closing }
// [ ] You have at least 3 comments total in your code
// [ ] Your program compiles and runs without errors
} // end main
} // end MyFirstApp