A telephone company charges to cents per minutefor all calls outside the customers area code that last over 20 minutes

A telephone company charges to cents per minutefor all calls outside the customers area code that last over 20 minutes .All other calls are 13 percents minute.Fields for each call include customer area code (three digits),customer phone number (seven digits),called area code (three digits),called number(seven digits)and called time in minutes(four digits).Display the customer area code,customer phone number,called area code,called number,called time in minutes and the total charge.Draw the flowchart for this program.

The correct answer and explanation is :

To address the problem of calculating telephone charges based on call duration and area codes, we can design a program that processes each call’s details and computes the total charge accordingly.

Problem Breakdown:

  • Input Fields:
  • Customer Area Code (3 digits)
  • Customer Phone Number (7 digits)
  • Called Area Code (3 digits)
  • Called Number (7 digits)
  • Call Duration in Minutes (up to 4 digits)
  • Charging Rules:
  • Calls outside the customer’s area code lasting over 20 minutes are charged at 10 cents per minute.
  • All other calls are charged at 13 cents per minute.

Steps to Solve:

  1. Input Collection:
  • Prompt the user to enter the customer area code, customer phone number, called area code, called number, and call duration.
  1. Charge Calculation:
  • If the call is outside the customer’s area code and lasts over 20 minutes:
    • Calculate the charge as: charge = call_duration * 0.10
  • Otherwise:
    • Calculate the charge as: charge = call_duration * 0.13
  1. Output:
  • Display the customer area code, customer phone number, called area code, called number, call duration, and the total charge.

Pseudocode:

START
    // Declare variables
    STRING customer_area_code, customer_phone_number, called_area_code, called_number
    INTEGER call_duration
    FLOAT charge

    // Input data
    PRINT "Enter customer area code:"
    INPUT customer_area_code
    PRINT "Enter customer phone number:"
    INPUT customer_phone_number
    PRINT "Enter called area code:"
    INPUT called_area_code
    PRINT "Enter called number:"
    INPUT called_number
    PRINT "Enter call duration in minutes:"
    INPUT call_duration

    // Calculate charge
    IF customer_area_code != called_area_code AND call_duration > 20 THEN
        charge = call_duration * 0.10
    ELSE
        charge = call_duration * 0.13
    ENDIF

    // Output results
    PRINT "Customer Area Code: ", customer_area_code
    PRINT "Customer Phone Number: ", customer_phone_number
    PRINT "Called Area Code: ", called_area_code
    PRINT "Called Number: ", called_number
    PRINT "Call Duration (minutes): ", call_duration
    PRINT "Total Charge ($): ", charge
STOP

Explanation:

  • Input Section: Collects necessary details about the call.
  • Charge Calculation: Determines the appropriate rate based on the area codes and call duration.
  • Output Section: Displays all relevant information, including the calculated charge.

Conclusion:

This approach ensures that each call is billed correctly based on the specified criteria. By following the outlined steps and utilizing the provided pseudocode, one can implement a program that accurately calculates telephone charges.

Scroll to Top