forked from Sneha0008/hacktoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabq5.java
More file actions
37 lines (37 loc) · 763 Bytes
/
Labq5.java
File metadata and controls
37 lines (37 loc) · 763 Bytes
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
class Commercial
{
private String name;
void setname(String name)
{
this.name=name;
}
String getname()
{
return name;
}
void CalculateBill(int unit) //calculating commercial bill
{
System.out.println("Commercial Customer= "+getname());
System.out.println("Bill amount= "+unit*5.00);
}
}
class Domestic extends Commercial
{
void CalculateBill(int unit) //calculating domestic bill
{
System.out.println("Domestic Customer= "+getname());
System.out.println("Bill amount= "+unit*2.50);
}
}
class Labq5
{
public static void main(String args[])
{
Commercial c = new Commercial();
c.setname("ABC");
c.CalculateBill(40);
Domestic d = new Domestic ();
d.setname("EFG");
d.CalculateBill(40);
}
}