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 :
Here is the structured approach to solving this problem, along with a flowchart representation of the logic.
Solution Breakdown:
- Understanding the Charges:
- Calls lasting over 20 minutes and outside the customer’s area code are charged $0.02 per minute.
- All other calls are charged $0.13 per minute.
- Input Fields Required:
- Customer area code (3 digits)
- Customer phone number (7 digits)
- Called area code (3 digits)
- Called phone number (7 digits)
- Call duration (up to 4 digits)
- Processing Logic:
- If the customer area code is different from the called area code and call duration is more than 20 minutes, charge $0.02 per minute.
- Otherwise, charge $0.13 per minute.
- Compute the total charge by multiplying the call duration by the respective rate.
- Output Fields:
- Customer Area Code
- Customer Phone Number
- Called Area Code
- Called Phone Number
- Call Duration
- Total Charge
Flowchart Explanation:
- Start the program.
- Input the customer area code, phone number, called area code, called number, and call duration.
- Check if the called area code is different from the customer’s area code.
- If yes, check if the call duration exceeds 20 minutes.
- If yes, apply a rate of $0.02 per minute.
- If no, apply a rate of $0.13 per minute.
- If no, apply a rate of $0.13 per minute.
- Calculate the total charge using the respective rate.
- Display the results.
- End the program.
Now, I will generate the flowchart image for better visualization.
Here is the flowchart for the telephone call charge calculation program.
Explanation of the Flowchart:
- Start: The program begins execution.
- Input Customer & Called Data: It collects details such as area codes, phone numbers, and call duration.
- Check if Called Area Code is Different:
- If yes, proceed to check if the call duration is more than 20 minutes.
- If no, apply a charge of $0.13 per minute.
- Check Call Duration > 20 minutes?:
- If yes, apply $0.02 per minute.
- If no, apply $0.13 per minute.
- Compute Total Charge: Multiply the call duration by the applicable rate.
- Display Output: Show the customer’s details along with the final charge.
- End: Program execution completes.
This structure ensures that the program calculates the charges correctly based on the conditions given in the problem.