Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to calculate the telephone charges for a number of customers. Th

ID: 3621551 • Letter: W

Question

Write a program to calculate the telephone charges for a number of customers. The data for each customer consists of :
PREVIOUS METER READING, PRESENT METER READING
The difference between the two readings gives the number of units used by the customer for the period under construction. The amount due for each customer is calculated by:
UNITS USED* RATE PER UNIT + RENTAL CHARGE
The rate per unit and rental charge is assumed to be the same for all customers and must be input once only.
Your program must:
a. Input the rate and rental charge.
b. Read the data for each customer and calculate the amount due.
c. Print the information under suitable headings.
d. Count and print the number of customers processed.
e. Calculate and print the total amount due to the telephone company.

Explanation / Answer

public class telephoneCompany { public static void main (String []args) { Scanner input= new Scanner (System.in); System.out.println("enter rate per unit"); double unitrate = input.nextDouble(); System.out.println("enter rental charges"); double rentalcharg = input.nextDouble(); System.out.println("enter customer number"); int num = input.nextInt(); int count =0; while (num!=0) { System.out.println("enter previous meter reading"); int preread = input.nextInt(); System.out.println("enter present meter reading"); int presRead = input.nextInt(); double units_used = preread - presRead; amtDue = (units_used*unitrate)+rentcharg; System.out.printf("customer %damount due is %.2f",num,amtDue); count ++; int total_customer = count; System.out.printf("the total number of customers entered are %d",count); double total_due = count *amtDue; System.out.printf("the total amount due to company is %.2f",total_due); } } }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote