import [Link].
*;
public class PhoneBill
private String customerName;
private long phoneNo;
private int no_of_unit;
private int rent;
private double amount;
public PhoneBill()
customerName = "";
phoneNo=0;
no_of_unit=0;
rent=0;
amount=0.0;
public void accept()
Scanner sc = new Scanner([Link]);
[Link]("Enter customer name: ");
customerName = [Link]();
[Link]("Enter phone number: ");
phoneNo = [Link]();
[Link]("Enter number of units(calls made): ");
no_of_unit = [Link]();
[Link]("Enter monthly rent: ");
rent = [Link]();
public void calculate()
int units = no_of_unit;
double callCharge = 0.0;
if(units > 50)
units -= 50;
if(units > 100)
callCharge += 100 * 0.80;
units -= 100;
if(units > 200)
callCharge += 200 * 1.00;
units -= 200;
callCharge += units * 1.20;
else
callCharge += units * 1.00;
else
callCharge += units * 0.80;
amount = rent + callCharge;
public void display()
[Link]("\nPhone Bill Details: ");
[Link]("Customer Name:"+customerName);
[Link]("Phone Number :"+phoneNo);
[Link]("Unit Used: "+no_of_unit);
[Link]("Rent:"+rent);
[Link]("Total Amount :Rs. %.2f\n",amount );
public static void main(String args[])
PhoneBill pb = new PhoneBill();
[Link]();
[Link]();
[Link]();