-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYT43.java
More file actions
82 lines (69 loc) · 1.68 KB
/
YT43.java
File metadata and controls
82 lines (69 loc) · 1.68 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//funn
import java.util.*;
public class YT43
{
String name;
double weight;
String address;
double bill;
char type;
public void accept()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the name");
name=sc.nextLine();
System.out.println("Enter the weight");
weight=sc.nextDouble();
System.out.println("Enter the type: D for Domestic & I for International");
type=sc.next().charAt(0);
sc.close();
}
public void calculate()
{
if(type=='I')
{
if(weight<=5)
{
bill=(weight*800)+1500;
}
else if(weight>=6 && weight<=10)
{
bill=(5*800)+(weight-5)*700+1500;
}
else
{
bill=(5*800)+(5*700)+(weight-10)*500+1500;
}
}
else
{
if(weight<=5)
{
bill=(weight*800);
}
else if(weight>=6 && weight<=10)
{
bill=(5*800)+(weight-5)*700;
}
else
{
bill=(5*800)+(5*700)+(weight-10)*500;
}
}
}
public void print()
{
System.out.println(name);
System.out.println(weight);
System.out.println(address);
System.out.println(bill);
System.out.println(type);
}
public static void main(String[] args)
{
YT43 c1= new YT43();
c1.accept();
c1.calculate();
c1.print();
}
}