Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A program is required to calculate the cost of a plumber s visit. If it is a non - urgent job, a plumber charges a
A program is required to calculate the cost of a plumbers visit. If it is a nonurgent job, a plumber charges a call out fee that also covers the first hour minutes of work. Each whole hour, or part of an hour, after that is charged at However, if it is an urgent job, the call out fee that covers the first hour is and each hour or part of an hour after that is charged at
So for example, if the plumber takes minutes to complete an urgent job, the first minutes costs The remaining minutes cost as there are complete hours and then part of an hour, which are each charged at making a total bill of For the same number of minutes for a nonurgent job, the total bill is for the call out and for the hours and part hour, so the total bill is
You are given part of the test data Table and an errorfilled program this can be downloaded from the assessment page
Table
Test number Input minutes urgent Expected output
True
True
True
False
False
False
# Problem: Calculate plumbers bill.
# Input: minutes worked
# Input: True if urgent, False otherwise
# Output: cost
minutes
urgent False
cost
hours
if minutes :
hours minutes
if minutes :
hours minutes
if urgent
cost hours
if not urgent:
cost hours
printcost
c
iExplain, in ordinary English, what the purpose of the first if statement is and how this is achieved in the Python code.
iiThis program is currently based on Pattern Explain why Pattern would be better at expressing the last two multiple cases.
iii.Using Pattern write an algorithm for this scenario. Your algorithm must initialise minutes and urgent to admissible values.
dThis part of the question involves writing Python code. Produce code corresponding to your algorithm. Include comments. Use the test table to check your code works. You do not need to submit test outputs.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started