diff options
Diffstat (limited to 'Java/InternetDelicatessen.java')
-rw-r--r-- | Java/InternetDelicatessen.java | 41 |
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 |