Pseudocode is a valuable tool for writing algorithms. It provides a way to write
ID: 3882847 • Letter: P
Question
Pseudocode is a valuable tool for writing algorithms. It provides a way to write out the major steps in an algorithm in a precise and unambiguous way, but it can be written without concern for the syntax of a specific programming language that will be used to implement the algorithm. This assignment will give you some additional practice writing pseudocode. Part 1-Writing Pseudocode Frank Jones owns PaveMasters, LLC and is looking for a script to add to his Web site that can calculate an estimate for customers who want to have their driveways paved. This script will allow potential customers to select common options and get an idea of Frank's prices. The script will support the following: The user must specify the length, width, type of material, and number of extra parking spaces desired as inputs. The minimum charge for any job is $1000. Given the length and width (in feet) of the driveway, the base cost is $5 for each square foot. The base price is for a gravel driveway. If the job is for an asphalt driveway, add $500. If it is for a concrete driveway, add $1000. For each addition parking space requested, add an extra $100. Answer the following questions. What is the cost for each of the following driveways? Show how you calculated the price. a. Length: 50 feet, Width: 5 feet, Type: Gravel, Parking Spaces: 0 b. Length: 100 feet, Width: 10 feet, Type: Asphalt, Parking Spaces: 2 c. Length: 600 feet, Width: 10 feet, Type: Concrete, Parking Spaces: 8 d. Length: 10 feet, Width: 5 feet, Type: Asphalt, Parking Spaces: 0 What would the pseudocode for this algorithm look like? Write out a completed algorithm using pseudocode.Explanation / Answer
==============================
Answer for Question :: 1
==============================
Pre-reuisites
1) User Inputs:
a) length
b) width
c) type of material
d)extra parking spaces
2) Procedure
a) Minimum charge for any job is $1000
b) The base cost per square foot is $5
c) if the material type is "asphalt" $500 needs to be charged
otherwise if the material type is "concrete" $1000 needs to be charged
d) For additional carparking space, $100 needs to be charged.
a)
Inputs:
--------
Length=50
Width = 5
Type: Gravel, I assumed as type of material is concrete
Number of Parking spaces : 0
Procedure
---------
min_charge = $1000
driveway_charge = Length * Width * $5 /* 50 * 5 * 5 ===> 1250 */
driveway_type_charge = 1000
parking_charge = 0
total_charge = min_charge + dirveway_charge + driveway_type_charge + parking_charge
/* 1000+1250+1000+0 ====> 3250 */
b)
Inputs:
-------
Length = 100
Width = 10
Type : Asphalt
No. of Parking spaces : 2
Procedure
---------
min_charge = $1000
driveway_charge = Length * Width * $5 /* 100 * 10 * 5 ====> 5000 */
driveway_type_charge = 500
parking_charge = 2 * 100 /* 2*100 ===> 200 */
total_charge = min_charge + dirveway_charge + driveway_type_charge + parking_charge
/* 1000 + 5000 + 500 + 200 ====> 6700 */
c)
Inputs:
-------
Length = 600
Width = 10
Type : Concrete
No. of Parking spaces : 8
Procedure
---------
min_charge = $1000
driveway_charge = Length * Width * $5 /* 600 * 10 * 5 ====> 30000 */
driveway_type_charge = 1000
parking_charge = 8 * 100 /* 8*100 ===> 800 */
total_charge = min_charge + dirveway_charge + driveway_type_charge + parking_charge
/* 1000 + 30000 + 1000 + 800 ====> 32800 */
d)
Inputs:
-------
Length = 10
Width = 5
Type : Asphalt
No. of Parking spaces : 0
Procedure
---------
min_charge = $1000
driveway_charge = Length * Width * $5 /* 10 * 5 * 5 ====> 250 */
driveway_type_charge = 500
parking_charge = 0
total_charge = min_charge + dirveway_charge + driveway_type_charge + parking_charge
/* 1000 + 250 + 500 + 0 ====> 1750 */
===========================
Answer for Question :: 2
===========================
step1 : read the values from the standard input device and store them into respective variables as follows
a) read length
b) read width
c) read material
d) read eps REM eps - extra parking space
step2 : min_charge = 1000
step3 : driveway_charge = length * width * 5
step4 : if material = "Asphlat" then
driveway_type_charge = 500
otherwise
driveway_type_charge = 1000
step5 : if eps > 0 then
parking_charge = eps * 100
otherwise
parking_charge = 0
step6 : total_charge = min_charge + driveway_charge + driveway_type_charge + parking_charge
step 7: stop.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.