- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdelivery.java
More file actions
Latest commit
74 lines (36 loc) · 1.83 KB
/
Copy pathdelivery.java
File metadata and controls
74 lines (36 loc) · 1.83 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
importjava.util.Scanner;
importjava.text.DecimalFormat;
publicclassdelivery {
publicstaticvoidmain (String [] args){
doubleIrish_Cost = 3.50;
doubleUK_Cost = 4.50;
doubleEurope_cost= 6.25;
finalScannerscanner = newScanner (System.in);
System.out.print("please enter the price of your purchase: ");
doublePurchaseCost = scanner.nextDouble();
System.out.print("\nplease enter the wight of your purchas in kilagrams (kg):");
doubleWightOfPurchas = scanner.nextDouble();
System.out.print("\nhere is the delivery location:");
System.out.print("\nEnter 1 for the EU: ");
System.out.print("\nEnter 2 for Ireland: ");
System.out.print("\nEnter 3 for The United Kingdom: ");
System.out.print("\nEnter one of the above: ");
doubleDeliveryCharges = 0.0;
finalintDeliveryCountry = scanner.nextInt();
if (DeliveryCountry == 1 ) {
DeliveryCharges = (Europe_cost * WightOfPurchas);
} elseif (DeliveryCountry == 2 ) {
DeliveryCharges = (Irish_Cost * WightOfPurchas);
} elseif (DeliveryCountry == 3 ) {
DeliveryCharges = (UK_Cost * WightOfPurchas);
} else {
System.err.println("Invalid delivery country entered. Exiting...");
}
DecimalFormatcurrencyFormat = newDecimalFormat("#,##0.00");
StringformattedDeliveryCharges = currencyFormat.format(DeliveryCharges);
StringformattedPurchaseCost = currencyFormat.format(PurchaseCost);
System.out.println("Your delivery charge is: $" + formattedDeliveryCharges + " " + formattedPurchaseCost);
scanner.close();
System.exit(0);
}
}