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. Below is an explanation of the program’s logic, followed by a flowchart illustrating the process.

Program Logic:

  1. Input Collection: Gather the following details for each call:
  • Customer’s area code (three digits)
  • Customer’s phone number (seven digits)
  • Called party’s area code (three digits)
  • Called party’s phone number (seven digits)
  • Call duration in minutes (up to four digits)
  1. Determine Call Type:
  • Compare the customer’s area code with the called party’s area code.
  • If they are the same, it’s a local call.
  • If they differ, it’s a non-local (long-distance) call.
  1. Calculate Charges:
  • Local Calls: Charged at a flat rate of 13 cents per minute, regardless of duration.
  • Non-Local Calls:
    • If the call lasts 20 minutes or less, it’s charged at 13 cents per minute.
    • If the call exceeds 20 minutes, it’s charged at 20 cents per minute for the entire duration.
  1. Output the Details:
  • Display the collected input details along with the calculated total charge for the call.

Flowchart:

Below is a flowchart that visually represents the program’s logic:

+---------------------------+
| Start                     |
+---------------------------+
           |
           v
+---------------------------+
| Input:                    |
| - Customer Area Code      |
| - Customer Phone Number   |
| - Called Area Code        |
| - Called Number           |
| - Call Duration (minutes) |
+---------------------------+
           |
           v
+---------------------------+
| Is Customer Area Code     |
| equal to Called Area Code?|
+---------------------------+
           |
   +-------+-------+
   |               |
   v               v
+----------------+ +---------------------------+
| Local Call     | | Non-Local Call            |
| (Same Area     | | (Different Area Codes)    |
| Codes)         | +---------------------------+
+----------------+           |
           |                 v
           v     +---------------------------+
+---------------------------+ | Is Call Duration > 20 mins? |
| Charge = Duration x 13¢   | +---------------------------+
+---------------------------+           |
                                 +-------+-------+
                                 |               |
                                 v               v
                      +------------------+ +------------------+
                      | Charge = Duration| | Charge = Duration|
                      | x 13¢            | | x 20¢            |
                      +------------------+ +------------------+
                                 |               |
                                 +-------+-------+
                                         |
                                         v
                           +---------------------------+
                           | Display:                  |
                           | - Customer Area Code      |
                           | - Customer Phone Number   |
                           | - Called Area Code        |
                           | - Called Number           |
                           | - Call Duration           |
                           | - Total Charge            |
                           +---------------------------+
                                         |
                                         v
                                 +----------------+
                                 | End            |
                                 +----------------+

Explanation:

The program begins by collecting all necessary inputs related to the call. It then checks if the call is local or non-local by comparing the area codes. For local calls, the charge is straightforward at 13 cents per minute. For non-local calls, the program further checks the duration to determine the appropriate rate: 13 cents per minute for calls up to 20 minutes and 20 cents per minute for longer calls. Finally, it displays all the call details along with the computed total charge.

Note: This flowchart provides a clear and structured approach to calculating telephone charges based on the given criteria.

Scroll to Top