summaryrefslogtreecommitdiffstats
path: root/Java/InternetDelicatessen.java
blob: 4cf78f97b21de413a0f5bf02ea3902e95c06e4bd (plain) (blame)
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
//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