-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRewards.java
More file actions
77 lines (75 loc) · 2.75 KB
/
Rewards.java
File metadata and controls
77 lines (75 loc) · 2.75 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
68
69
70
71
72
73
74
75
76
77
import java.util.Scanner;
public class Rewards {
int points;
public Rewards(int points){
this.points = points;
}
public String showRewards(int rewardPoints){
String s;
if (rewardPoints >= 5000) {
s = "1) free coffee - 50 pts\n2) free baked good - 100 pts\n3) free specialty coffee - 200 pts\n4) 1% store ownership = 5000 pts";
}
else if (rewardPoints >= 200){
s = "1) free coffee - 50 pts\n2) free baked good - 100 pts\n3) free specialty coffee - 200 pts";
}
else if (rewardPoints >= 100){
s = "1) free coffee - 50 pts\n2) free baked good - 100 pts";
}
else if (rewardPoints >= 50) {
s = "1) free coffee - 50 pts";
}
else{
s = "Not enough points";
}
return "Choices:\n" + s;
}
public String getReward(int choice){
switch (choice){
case 1:
if (points >= 50){
return "You have selected a free coffee! Remaining number of points: " + (points-50);
}
else{
return "You do not have enough points for that reward.";
}
case 2:
if (points >= 100){
return "You have selected a free baked good! Remaining number of points: " + (points-100);
}
else{
return "You do not have enough points for that reward.";
}
case 3:
if (points >= 200){
return "You have selected a free specialty coffee! Remaining number of points: " + (points-200);
}
else{
return "You do not have enough points for that reward.";
}
case 4:
if (points >= 5000){
return "You have selected 1% store ownership! Remaining number of points: " + (points-5000);
}
else{
return "You do not have enough points for that reward.";
}
default:
return "Invalid choice, please select again.";
}
}
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("Please enter number of points:");
int pts = sc.nextInt();
Rewards cust = new Rewards(pts);
String show = cust.showRewards(pts);
System.out.println(show);
if (pts >= 50){
System.out.println("Enter your choice number:");
int choice = sc.nextInt();
String get = cust.getReward(choice);
System.out.println(get);
}
sc.close();
}
}