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); }
}
}
ICAgIAogICAgIAogICAgICAgIGltcG9ydCBqYXZhLmlvLio7CmNsYXNzIGNhbGN1bGF0ZWJpbGwKewogICAgZG91YmxlIGJpbGxwYXk7CiAgICB2b2lkIGJpbGwobG9uZyB1bml0cykKICAgIHsKICAgICAgICBpZih1bml0czwxMDApCiAgICAgICAgYmlsbHBheT11bml0cyoxLjIwOwogICAgICAgIGVsc2UgaWYodW5pdHM8MzAwKQogICAgICAgIGJpbGxwYXk9MTAwKjEuMjArMjAwKjIrKHVuaXRzLTEwMCkqMjsKICAgICAgICBlbHNlIGlmKHVuaXRzPjMwMCkKICAgICAgICBiaWxscGF5PTEwMCoxLjIwKzIwMCoyKyh1bml0cy0zMDApKjM7CiAgICB9CiAgIH0KICAgY2xhc3MgY29tcHV0ZWVsZWN0cmljaXR5YmlsbCBleHRlbmRzIGNhbGN1bGF0ZWJpbGwKICAgewogICAgICAgcHVibGljIHN0YXRpYyB2b2lkIG1haW4oU3RyaW5nIGFyZ3NbXSkKICAgICAgIHsKICAgICAgICAgICBsb25nIHVuaXRzOwogICAgICAgICAgIERhdGFJbnB1dFN0cmVhbSBpbiA9IG5ldyBEYXRhSW5wdXRTdHJlYW0oU3lzdGVtLmluKTsKICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oImNhbGN1bGF0ZSBiaWxsIHVzaW5nIGluaGVyaXRhbmNlIik7CiAgICAgICAgICAgdHJ5CiAgICAgICAgICAgewogICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oImVudGVyIG5vIG9mIHVuaXRzOiIpOwogICAgICAgICAgICAgICB1bml0cz1JbnRlZ2VyLnBhcnNlSW50KGluLnJlYWRMaW5lKCkpOwogICAgICAgICAgICAgICBjb21wdXRlZWxlY3RyaWNpdHliaWxsIGI9IG5ldyBjb21wdXRlZWxlY3RyaWNpdHliaWxsKCk7CiAgICAgICAgICAgICAgIGIuYmlsbCh1bml0cyk7CiAgICAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbigiYmlsbCB0byBwYXk6IitiLmJpbGxwYXkpOwogICAgICAgICAgIH0KICAgICAgICAgICBjYXRjaChFeGNlcHRpb24gZSl7fQogICAgICAgfQogICB9ICAgIAogICAgICAgICAgICAKICAgICAgICAgICAgIAogICAgICAgICAgICAgCiAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgCiAgICAK