Repository navigation
Expand file tree
/
Copy pathEcommercePlatform.java
More file actions
69 lines (67 loc) · 2.37 KB
/
Copy pathEcommercePlatform.java
File metadata and controls
69 lines (67 loc) · 2.37 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
import java.util.*;
public class EcommercePlatform {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
System.out.println("Base Price: ");
double basePrice = scn.nextDouble();
scn.nextLine();
System.out.println("Membership Level: ");
String membership = scn.nextLine();
System.out.println("Purchase Time: ");
String timeInput = scn.nextLine();
int hour = Integer.parseInt(timeInput.substring(0, 2));
System.out.println("Product Category: ");
String category = scn.nextLine();
System.out.println("Season: ");
String season = scn.nextLine();
double discount = 0;
switch (membership) {
case "Bronze":
discount = 0.05;
break;
case "Silver":
discount = 0.10;
break;
case "Gold":
discount = 0.15;
break;
case "Platinum":
discount = 0.20;
break;
default:
System.out.println("Please enter an acceptable membership level.");
return;
}
basePrice = basePrice - (basePrice * discount);
if (hour >= 0 && hour < 6) {
basePrice = basePrice - (basePrice * 0.10);
} else if (hour >= 12 && hour < 14) {
basePrice = basePrice - (basePrice * 0.05);
}
double newd = 0;
switch (category) {
case "Clothing":
newd = 0.05;
break;
case "Groceries":
newd = 0;
break;
case "Books":
newd = 0.03;
break;
}
basePrice = basePrice - (basePrice * newd);
if (category.equals("Electronics")) {
basePrice = basePrice + (basePrice * 0.02);
} else if (category.equals("Furniture")) {
basePrice = basePrice + (basePrice * 0.07);
}
if ((category.equals("Clothing") || category.equals("Furniture")) && season.equals("Spring")) {
basePrice = basePrice - (basePrice * 0.05);
}
if (category.equals("Electronics") && season.equals("Winter")) {
basePrice = basePrice - (basePrice * 0.10);
}
System.out.printf("Final price: %.2f TL\n", basePrice);
}
}