-
Notifications
You must be signed in to change notification settings - Fork 0
/
Week2Practice.java
84 lines (65 loc) · 1.67 KB
/
Week2Practice.java
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package week2;
import java.util.Scanner;
public class Week2Practice {
public static void main(String[] args) {
char grade = 'D';
switch (grade) {
case 'A':
System.out.println("90%");
break;
case 'B':
System.out.println("80%");
break;
case 'C':
System.out.println("70%");
break;
default:
System.out.println("0%");
}
if (5 == 5) {
if (4 == 3) {
System.out.println("5 is 5 and 4 is 4");
} else {
System.out.println("5 is 5");}
for (int i = 1; i <= 10; i++) {
System.out.println(i);
}
int x = 10;
while (x >10) {
System.out.println(x);
x++;
}
Scanner sc = new Scanner(System.in);
System.out.println("Enter your name: ");
String name1 = sc.nextLine();
System.out.println("Welcome, " + name1);
int selection = 0;
double total = 0;
while (selection != 4){
System.out.println("Select an option.");
System.out.println("1) add candybar to shopping cart: 1.99");
System.out.println("2) add cheese to shopping cart: 6.95");
System.out.println("3) add soccer ball to shopping cart: 12.99");
System.out.println("4) checkout");
selection = sc.nextInt();
switch (selection) {
case 1:
total += 1.99;
break;
case 2:
total += 6.95;
break;
case 3:
total += 12.99;
break;
case 4:
break;
default:
System.out.println("Please pick a valid option.");
}
System.out.println("Your current total is: " + total);
System.out.println("hello world".charAt(0) != 'H');
}
}
}
}