-
Notifications
You must be signed in to change notification settings - Fork 0
/
Shipping.java
95 lines (81 loc) · 2.58 KB
/
Shipping.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//The input for weight of package should be tested with numerical values between 1-20.
//The input for distance should be tested with numerical values between 1-1500.
//The values can be changed within the program to except numerical inputs outside of the ranges.
import java.util.Scanner;
public class Shipping
{
public static void main(String[] args)
{
double weight_of_package = 0;
double distance = 0;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter weight of package: ");
weight_of_package = keyboard.nextDouble();
System.out.print("Enter distance: ");
distance = keyboard.nextDouble();
double rate_1 = 1.10;
double rate_2 = 2.10;
double rate_3 = 3.10;
double rate_4 = 4.00;
if(weight_of_package <= 2)
{
if(distance <= 500)
{
System.out.println("Shipping Charge: " + ((distance * rate_1) / 500));
}
else if(distance > 500 && distance <= 1000)
{
System.out.println("Shipping Charge: " + ((((distance - 500) * rate_1) / 500) + (rate_1)));
}
else if(distance > 1000 && distance <= 1500)
{
System.out.println("Shipping Charge: " + ((((distance - 1000) * rate_1) / 500) + (rate_1 * 2)));
}
}
if(weight_of_package > 2 && weight_of_package <= 6)
{
if(distance <= 500)
{
System.out.println("Shipping Charge: " + ((distance * rate_2 ) / 500));
}
else if(distance > 500 && distance <= 1000)
{
System.out.println("Shipping Charge: " + ((((distance - 500) * rate_2 ) / 500) + (rate_2)));
}
else if(distance > 1000 && distance <= 1500)
{
System.out.println("Shipping Charge: " + ((((distance - 1000) * rate_2) / 500) + (rate_2 * 2)));
}
}
if(weight_of_package > 6 && weight_of_package <= 10)
{
if(distance <= 500)
{
System.out.println("Shipping Charge: " + ((distance * rate_3) / 500));
}
else if(distance > 500 && distance <= 1000)
{
System.out.println("Shipping Charge: " + ((((distance - 500) * rate_3) / 500) + (rate_3)));
}
else if(distance > 1000 && distance <= 1500)
{
System.out.println("Shipping Charge: " + ((((distance - 1000) * rate_3) / 500) + (rate_3 * 2)));
}
}
if(weight_of_package > 10)
{
if(distance <= 500)
{
System.out.println("Shipping Charge: " + (((distance * rate_4 ) / 500)));
}
else if(distance > 500 && distance <= 1000)
{
System.out.println("Shipping Charge: " + (((((distance - 500) * rate_4 ) / 500) + (rate_4))));
}
else if(distance > 1000 && distance <= 1500)
{
System.out.println("Shipping Charge: " + ((((distance - 1000) * rate_4) / 500) + (rate_4 * 2)));
}
}
}
}