-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfruitShop.java
More file actions
82 lines (78 loc) · 2.58 KB
/
Copy pathfruitShop.java
File metadata and controls
82 lines (78 loc) · 2.58 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
78
79
80
81
import java.util.Scanner;
public class fruitShop {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String fruit = scanner.nextLine();
String day = scanner.nextLine();
double amount = Double.parseDouble(scanner.nextLine());
float foodPrize = 0.00f;
switch (day) {
case "Monday":
case "Tuesday":
case "Wednesday":
case "Thursday":
case "Friday":
switch (fruit) {
case "banana":
foodPrize = 2.50f;
break;
case "apple":
foodPrize = 1.20f;
break;
case "orange":
foodPrize = 0.85f;
break;
case "grapefruit":
foodPrize = 1.45f;
break;
case "kiwi":
foodPrize = 2.70f;
break;
case "pineapple":
foodPrize = 5.50f;
break;
case "grapes":
foodPrize = 3.85f;
break;
default:
System.out.println("error");
break;
}
break;
case "Sunday":
case "Saturday":
switch (fruit) {
case "banana":
foodPrize = 2.70f;
break;
case "apple":
foodPrize = 1.25f;
break;
case "orange":
foodPrize = 0.9f;
break;
case "grapefruit":
foodPrize = 1.60f;
break;
case "kiwi":
foodPrize = 3.00f;
break;
case "pineapple":
foodPrize = 5.60f;
break;
case "grapes":
foodPrize = 4.20f;
break;
default:
System.out.println("error");
break;
}
break;
default:
System.out.println("error");
}
if (foodPrize != 0) {
System.out.printf("%.2f", foodPrize * amount);
}
}
}