Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Used the python program Write a Python program that computes the cost of a long-distance call. The cost of the call is determined according to

Used the python program

Write a Python program that computes the cost of a long-distance call.

The cost of the call is determined according to the following rate schedule:

a. Any call started between 8:00 A.M. and 6:00 P.M., Monday through Friday, is billed at a rate of $0.40 per minute.

b. Any call starting before 8:00 A.M. or after 6:00 P.M., Monday through Friday, is charged at a rate of $0.25 per minute.

c. Any call started on a Saturday or Sunday is charged at a rate of $0.15 per minute.

The input will consist of the day of the week, the time the call started, and the length of the call in minutes. The output will be the cost of the call. The time is to be input in 24-hour notation, so the time 1:30 P.M. is input as (must be the following format, the user types in the colon): 13:30

The day of the week will be read as one of the following pairs of character values, which are stored in two variables of type string (ex. a, b = "Mo"): Mo Tu We Th Fr Sa Su

Be sure to allow the user to use either uppercase or lowercase letters or a combination of the two. The number of minutes will be input as a value of integer.

Format your output to two decimal places.

Define the following lists and fill the lists using the two functions (createList() and fillList()):

Calling the functions (copy the following statements into your program):

hoursList = createList(24)

fillList (24, hoursList)

minutesList = createList(60)

fillList (60, minutesList)

hoursList = [0, 1, 2, .........., 22, 23] minutesList = [0, 1, 2, .........., 58, 59] 

Define the following lists and fill the lists manually (copy the following code and paste into your program):

daysList = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'] responseList = ['y', 'n']

Define the following functions:

createList(listSize): accepts a listSize as a argument, create a 1-D list called timeList with the listSize (initial values: zeros), and returns the timeList list.

fillList(listSize, timeList): accepts a listSize and the list returned by createList() as arguments, and fill the passed list. This is a void function.

collectUserInputTime(): accepts no arguments, collects call starting time in 24-hour notation, and returnsstartHour and startMinute as string data type.

validateUserInputTime(startHour, startMinute): accepts the startHour and startMinute returned bycollectUserInputTime() as arguments, validates the user's time input by comparing to the lists calledhoursList and minutesList, and returns True, startHour (integer), startMinute (integer) if the input is valid, or False if the input is invalid.

collectUserInputDay(): accepts no arguments, collects a day (two characters) save as firstDayCharacterand secondDayCharacter, and returns firstDayCharacter and secondDayCharacter as string data type. Allow uppercase and lowercase input (ex. MO, Mo, mo, and mO).

validateUserInputDay(firstDayCharacter, firstDayCharacter): accepts the firstDayCharacter andsecondDayCharacter returned by collectUserInputDay(), validates the user's day input by comparing the input to the daysList list, and returns True if the input is valid, or False if the input is invalid.

collectUserInputCallLength(): accepts no arguments, collects call length in in 24-hour notation, and returnscallLengthHour and callLengthMinute as string data type.

validateUserInputCallLength(callLengthHour, callLengthHour): accepts the callLengthHour andcallLengthMinute as arguments returned by collectUserInputCallLength(), validates the user's call length input (callLengthHour and callLengthMinute should be greater than or equal to zero), and returns True,callLengthHour (integer), callLengthMinute (integer) if the input is valid, or False if the input is invalid.

calculateTotalCost(startHour, startMinute, firstDayCharacter, secondDayCharacter, callLengthHour, callLengthMinute): Accepts arguments (startHour, startMinute, firstDayCharacter, secondDayCharacter, callLengthHour, callLengthMinute), calculate the total cost of a call, and returns the total cost (float).

collectUserInputYesNo(): accepts no arguments, collects 'y' or 'n' save as YesOrNo, and returns YesOrNo as string data type. Allow uppercase and lowercase input (ex. Y, y, N, n).

validateUserInputYesNo(YesOrNo): accepts the YesOrNo an argument returned bycollectUserInputYesNo(), validates the user's input by comparing the input to the responseList list, and returns True if the input is valid, or False if the input is invalid.

clearPreviousOutput(YesOrNo ): accepts the YesOrNo an argument. If the response is 'y' or 'Y', then clear the previous output, otherwise doesn't clear the previous output.

image text in transcribedimage text in transcribed

Enter the time the call starts in 24-hour rotation: 13:10 Enter the first two letters of the day of the week: Invalid day input. Please try again Enter the first two letters of the day of the week: Enter the time the call starts in 24-hour rotation: 13:10 Enter the first two letters of the day of the week: Mo Enter the length of the call in (hours:minutes) -10: 1? Invalid call length input. Please try again Enter the length of the call in (hours:minutes)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions