Answered step by step
Verified Expert Solution
Link Copied!

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 non-urgent job, a plumber charges a 100 call out fee that also covers the first hour (60 minutes) of work. Each whole hour, or part of an hour, after that is charged at 50. However, if it is an urgent job, the call out fee (that covers the first hour) is 200 and each hour or part of an hour after that is charged at 80.
So, for example, if the plumber takes 183 minutes to complete an urgent job, the first 60 minutes costs 200. The remaining 123 minutes cost 240 as there are 2 complete hours and then part of an hour, which are each charged at 80, making a total bill of 440. For the same number of minutes for a non-urgent job, the total bill is 100 for the call out and 150 for the hours and part hour, so the total bill is 250.
You are given part of the test data (Table 3) and an error-filled program (this can be downloaded from the assessment page).
Table 3
Test number Input minutes urgent Expected output
1119 True 280
2120 True 280
3121 True 360
4119 False 150
5120 False 150
6121 False 200
# Problem: Calculate plumbers bill.
# Input: minutes worked
# Input: True if urgent, False otherwise
# Output: cost
minutes =61
urgent = False
cost =0
hours =1
if minutes >60 :
hours = minutes //60
if minutes %60==0 :
hours = minutes //601
if urgent
cost =200+ hours *80
if not urgent:
cost =100+ hours *50
print(cost)
c.
i.Explain, in ordinary English, what the purpose of the first if statement is and how this is achieved in the Python code.
ii.This program is currently based on Pattern 4.3. Explain why Pattern 4.2 would be better at expressing the last two multiple cases.
iii.Using Pattern 4.2 write an algorithm for this scenario. Your algorithm must initialise minutes and urgent to admissible values.
d.This 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

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

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

What is involved in formulating a conjoint analysis problem?

Answered: 1 week ago

Question

Explain methods of metal extraction with examples.

Answered: 1 week ago