-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathebill.java
73 lines (72 loc) · 1.24 KB
/
ebill.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
import java.util.Scanner;
class bill
{
String cname;
String type;
int cmr,pmr,cno;
int amount,units;
void input()
{
Scanner input=new Scanner(System.in);
Scanner sc=new Scanner(System.in);
System.out.println("Enter cname:\n");
cname=sc.nextLine();
System.out.println("Enter cno:\n");
cno=input.nextInt();
System.out.println("Enter type");
type=sc.nextLine();
System.out.println("Enter cmr:\n");
cmr=input.nextInt();
System.out.println("Enter pmr:\n");
pmr=input.nextInt();
}
void cal()
{
units=cmr-pmr;
if(type.equals("DOM"))
{
if(units<=100)
amount=1*units;
else if(units>100 && units<=200)
amount=2*units;
else if(units>200 && units<=500)
amount=6*units;
else
;
}
else if(type.equals("COM"))
{
if(units<=100)
amount=units*2;
else if(units>100 && units<=200)
amount=units*4;
else if(units>200 && units<=500)
amount=units*6;
else if(units>500)
amount=units*7;
}
else
{
System.out.println("Enter valid input\n");
}
}
void display()
{
System.out.println("Units used is:"+units);
System.out.println("Amount to be paid is:"+amount);
}
}
class ebill
{
public static void main(String[]args)
{
bill B=new bill();
B.input();
B.cal();
B.display();
bill B1=new bill();
B1.input();
B1.cal();
B1.display();
}
}