import java.io.*;
class calculatebill
{
double billpay;
void bill(long units)
{
if(units<100)
billpay=units*1.20;
else if(units<300)
billpay=100*1.20+200*2+(units-100)*2;
else if(units>300)
billpay=100*1.20+200*2+(units-300)*3;
}
}
class computeelectricitybill extends calculatebill
{
public static void main
(String args
[]) {
long units;
System.
out.
println("calculate bill using inheritance"); try
{
System.
out.
println("enter no of units:"); units
=Integer.
parseInt(in.
readLine()); computeelectricitybill b= new computeelectricitybill();
b.bill(units);
System.
out.
println("bill to pay:"+b.
billpay); }
}
}
aW1wb3J0IGphdmEuaW8uKjsKY2xhc3MgY2FsY3VsYXRlYmlsbAp7CiAgICBkb3VibGUgYmlsbHBheTsKICAgIHZvaWQgYmlsbChsb25nIHVuaXRzKQogICAgewogICAgICAgIGlmKHVuaXRzPDEwMCkKICAgICAgICBiaWxscGF5PXVuaXRzKjEuMjA7CiAgICAgICAgZWxzZSBpZih1bml0czwzMDApCiAgICAgICAgYmlsbHBheT0xMDAqMS4yMCsyMDAqMisodW5pdHMtMTAwKSoyOwogICAgICAgIGVsc2UgaWYodW5pdHM+MzAwKQogICAgICAgIGJpbGxwYXk9MTAwKjEuMjArMjAwKjIrKHVuaXRzLTMwMCkqMzsKICAgIH0KICAgfQogICBjbGFzcyBjb21wdXRlZWxlY3RyaWNpdHliaWxsIGV4dGVuZHMgY2FsY3VsYXRlYmlsbAogICB7CiAgICAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmcgYXJnc1tdKQogICAgICAgewogICAgICAgICAgIGxvbmcgdW5pdHM7CiAgICAgICAgICAgRGF0YUlucHV0U3RyZWFtIGluID0gbmV3IERhdGFJbnB1dFN0cmVhbShTeXN0ZW0uaW4pOwogICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiY2FsY3VsYXRlIGJpbGwgdXNpbmcgaW5oZXJpdGFuY2UiKTsKICAgICAgICAgICB0cnkKICAgICAgICAgICB7CiAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiZW50ZXIgbm8gb2YgdW5pdHM6Iik7CiAgICAgICAgICAgICAgIHVuaXRzPUludGVnZXIucGFyc2VJbnQoaW4ucmVhZExpbmUoKSk7CiAgICAgICAgICAgICAgIGNvbXB1dGVlbGVjdHJpY2l0eWJpbGwgYj0gbmV3IGNvbXB1dGVlbGVjdHJpY2l0eWJpbGwoKTsKICAgICAgICAgICAgICAgYi5iaWxsKHVuaXRzKTsKICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJiaWxsIHRvIHBheToiK2IuYmlsbHBheSk7CiAgICAgICAgICAgfQogICAgICAgICAgIGNhdGNoKEV4Y2VwdGlvbiBlKXt9CiAgICAgIAogICAgICAgICAgIAogICAgICAKICAgICAgIH0KICAgfQ==