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 1

A program is required to calculate the cost of a plumber's 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
# Problen: Calculate plunber's bill.
# Input: ninutes worked
# Input: True if urgent, False othervise
# Output: cost
minutes =61
urgent = False
cost =8
hours =1
if minutes >60 :
hours = nimutes ??68
if ninutes 60=0 :
hours = ninutes ??60-1
if urgent
cost =290+ hours *98
if not urgent:
cost =190+ hours *58
print(cost)
a.
i.Describe the inputs of this program, including their admissible values.
ii.Give an explanation for the choice of input values shown in the test table.
iii.Describe how you would extend the testing strategy to ensure that the program works for shorter jobs.
(6 marks)
b.
i.What are the syntax errors in this program? Consider no other errors at this point.
ii.Correct the syntax errors. Now test your program for a non-urgent job of 59 minutes. Explain why the code fails.
(4 marks)
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.
(9 marks)
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.
Name your Python file Q4_OUCU.py, where OUCU is your OU computer username, e.g. abc123. Then include the code file in your TMA zip file.
Paste your completed Python code into your solution document as text, using an evenly spaced font such as Courier New or Consolas.
(4 marks)
image text in transcribed

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

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions

Question

4. Describe the factors that influence self-disclosure

Answered: 1 week ago

Question

1. Explain key aspects of interpersonal relationships

Answered: 1 week ago