summaryrefslogtreecommitdiffstats
path: root/Java/InternetDelicatessen.java
diff options
context:
space:
mode:
authormsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
committermsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
commit9d53d8857eaa1c9405894a88ca75bc4657e42f35 (patch)
treeeb1efc1d028b949dd83bb710c68be8eff58f26e7 /Java/InternetDelicatessen.java
downloadschool-code-9d53d8857eaa1c9405894a88ca75bc4657e42f35.tar.gz
school-code-9d53d8857eaa1c9405894a88ca75bc4657e42f35.tar.bz2
school-code-9d53d8857eaa1c9405894a88ca75bc4657e42f35.zip
Inital CommitHEADmaster
Diffstat (limited to 'Java/InternetDelicatessen.java')
-rw-r--r--Java/InternetDelicatessen.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/Java/InternetDelicatessen.java b/Java/InternetDelicatessen.java
new file mode 100644
index 0000000..4cf78f9
--- /dev/null
+++ b/Java/InternetDelicatessen.java
@@ -0,0 +1,41 @@
+//BufferedReader is faster than scanner as it doesn't parse the text. Iterated over 1000 times, it saves 30 seconds in total.
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+class InternetDelicatessen {
+ public static void main(String[] args) throws java.io.IOException {
+ int amount;
+ float price;
+ float shipping = 0;
+ boolean overnight;
+ System.out.println("Item Name:");
+ BufferedReader itemI = new BufferedReader(new InputStreamReader(System.in));
+ String item = itemI.readLine();
+ System.out.println("Price");
+ BufferedReader priceI = new BufferedReader(new InputStreamReader(System.in));
+ price = Float.parseFloat(priceI.readLine());
+ System.out.println("Overnight Delivery (true or false):");
+ BufferedReader overnightI = new BufferedReader(new InputStreamReader(System.in));
+ overnight = Boolean.parseBoolean(overnightI.readLine());
+ System.out.println("Invoice: ");
+ System.out.println(item + " : $" + price);
+ //Regular Shipping
+ if (price < 10) {
+ shipping = shipping + 2;
+ } else{
+ shipping = shipping + 3;
+ }
+
+ //overnight or naw
+ if (overnight) {
+ shipping = shipping + 5;
+ }
+ float total = shipping + price;
+ System.out.println("shipping : $" + shipping);
+ System.out.println("total : $" + total);
+
+
+ }
+}
+
+//By msglm; Licensed under the AGPL v3