-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustom_order.java
122 lines (77 loc) · 4.03 KB
/
custom_order.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Code for Beginning Java's Cake & Cupcake Shop Tutorial
import java.util.Scanner; // Needed for the Scanner class to read input
public class custom_order {
// STEP 1 PRINTING HELLO WORLD TO CONSOLE
public static void main(String[] args) {
// System.out.println("Hello World!"); // print Hello World to console
// TEST CODE
// STEP 2 CREATE A SCANNER OBEJCT, DECLARE VARAIBLES, & PRINT STATEMENTS
Scanner keyboard = new Scanner (System.in);
String firstName; // Users first name
String itemOrder; // Item ordered
String frostingType; //Frosting ordered
String fillingType; // Filling ordered
String toppings; // Toppings ordered
String input; // User input
double cost = 15.00; // Cost of cake and cupcakes
final double TAX_RATE = 0.08; //Sales tax rate
double tax; // Amount of tax
// Introduce shop and prompt user to input first name
System.out.println("Welcome to Javas Cake and Cupcake Shop!");
System.out.println("We make custom cakes with our secret cake batter!");
// TEST CODE
// STEP 3 INPUT YOUR NAME AND PREPARE TO VIEW MENU
System.out.print("What is your first name?");
firstName = keyboard.nextLine();
System.out.print(firstName + ", please see our MENU below: ");
System.out.print("\n");
// TEST CODE
// STEP 4 DISPLAY MENU
System.out.println("________________________________________________");
System.out.println(" MENU QUANTITY BASE COST ");
System.out.println("________________________________________________");
System.out.println(" Cake 1 £15 ");
System.out.println(" Set of cupcakes 6 £15 ");
System.out.println("------------------------------------------------");
System.out.println("Frostings (vanilla, chocolate, strawberry, coco)");
System.out.println("Fillings (mocha, mint, lemon, caramel, vanilla )");
System.out.println("Toppings (sprinkles, cinnamon, cocoa, nuts )");
System.out.println("________________________________________________");
// TEST CODE
// STEP 5 PROMPT USER TO ORDER
System.out.println("Do you want cupacakes or a cake? Please select ONE");
itemOrder = keyboard.nextLine();
// TEST CODE
// STEP 6 PROMPT USER TO CHOOSE FROSTING
System.out.println("What type of frosting would you like? Please select ONE");
System.out.println("Vanilla, Chocolate, Strawberry or Coco");
frostingType = keyboard.nextLine();
//TEST CODE
// STEP 7 PROMPT USER TO CHOOSE FILLING
System.out.println("What type of FILLING do you want? ");
System.out.println("Mocha, Mint, Lemon, Caramel or Raspberry");
fillingType = keyboard.nextLine();
// TEST CODE
// STEP 8 PROMPT USER TO CHOOSE TOPPINGS
System.out.println("What type of TOPPINGS do you want? ");
System.out.println("Sprinkles, Cinnamon, Cocoa, Nuts");
toppings = keyboard.nextLine();
// TEST CODE
// STEP 9 DISPLAY ORDER CONFIRMATION
System.out.println("");
System.out.println(firstName + ", your order is as follows: ");
System.out.println("________________________________________");
System.out.println("Item ordered: " + itemOrder);
System.out.println("Frosting: " + frostingType);
System.out.println("Filling: " + fillingType);
System.out.println("Toppings: " + toppings);
System.out.println("________________________________________");
// TEST CODE
// STEP 10 DISPLAY COST AND SALES TAX
System.out.printf("The cost of your order is: £%.2f\n", cost);
tax = cost * TAX_RATE;
System.out.printf("The tax is: £%.1f\n", tax);
System.out.printf("The total cost due is: £%.2f\n", (tax + cost));
// Added a comment to track a change in the file
}
}