-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrder.java
More file actions
53 lines (47 loc) · 1.15 KB
/
Copy pathOrder.java
File metadata and controls
53 lines (47 loc) · 1.15 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
import java.util.Scanner;
class Order {
@SuppressWarnings("resource")
public static void main(String[] args) {
int distance , quantity, cost, Amount,charge =0;
int type;
Scanner sc = new Scanner (System.in);
System.out.println("Enter the type of food\n1 for veg \n2 for Non-veg");
type = sc.nextInt();
System.out.println("Quantity to order");
quantity = sc.nextInt();
System.out.println("Distance");
distance = sc.nextInt();
if(type == 1 || type == 2 && quantity >=1 && distance >=0){
if (type== 1){
cost = 12;
if(distance<=3){
charge = 0;
}
else if (distance >3 && distance<= 6){
charge = 1;
}
else if (distance >6){
charge = 2;
}
Amount = quantity*cost+charge;
System.out.println("Amount to be paid "+ Amount);
}
else{
cost =15;
if(distance<=3){
charge = 0;
}
else if (distance >3 && distance<= 6){
charge = 1;
}
else if (distance >6){
charge = 2;
}
Amount = quantity*cost+charge;
System.out.println("Amount to be paid "+ Amount);
}
}
else{
System.out.println("Select the Correct type of food");
}
}}