-
Notifications
You must be signed in to change notification settings - Fork 627
/
Copy pathShipingCostCalculator.java
45 lines (27 loc) · 1.01 KB
/
ShipingCostCalculator.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
import java.util.Scanner;
public class ShipingCostCalculator {
public static void main(String[] args)
{
Scanner scanner = new Scanner(System.in);
System.out.println("Enter the weight of your package (kg) : \t ");
double weight = scanner.nextDouble();
System.out.println("Select a shipping method:");
System.out.println("1. Standard Shipping");
System.out.println("2. Express Shipping");
int shippingMethod = scanner.nextInt();
double cost;
switch (shippingMethod) {
case 1:
cost = weight * 5.0; // Standard shipping rate
break;
case 2:
cost = weight * 10.0; // Express shipping rate
break;
default:
System.out.println("Invalid shipping method.");
return;
}
System.out.println("Shipping cost: $" + cost);
scanner.close();
}
}