0% found this document useful (0 votes)
39 views3 pages

Assignment 3 Memo

The assignment requires designing algorithms for two problems: calculating discounts based on pricing codes and determining an architect's fee based on building costs. The first problem involves using a CASE structure to apply discounts and print the original price, discount amount, and discounted price. The second problem utilizes nested IF statements to compute the architect's fee based on specified cost thresholds and percentages.

Uploaded by

yajosor762
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views3 pages

Assignment 3 Memo

The assignment requires designing algorithms for two problems: calculating discounts based on pricing codes and determining an architect's fee based on building costs. The first problem involves using a CASE structure to apply discounts and print the original price, discount amount, and discounted price. The second problem utilizes nested IF statements to compute the architect's fee based on specified cost thresholds and percentages.

Uploaded by

yajosor762
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

ASSIGNMENT 3 [30 Marks]

Due Date: 12 April 2023

In the following problems, you will need to:


• define the problem by constructing an IPO diagram
• create a solution algorithm using pseudocode
• desk check the solution algorithm using trace tables.

1 Design an algorithm (using the CASE structure) that will prompt a terminal
operator for the price of an article and a pricing code. Your program is then to calculate
a discount rate according to the pricing code and print to the screen the original price
of the article, the discount amount and the new discounted price. Calculate the pricing
code and accompanying discount amount as follows: [15]
Pricing code Discount rate
H 50%
F 40%
T 33%
Q 25%
Z 0%

if the pricing code is Z, the words “No discount” are to be printed on the screen. If the
pricing code is not H, F, T, Q or Z, the words “Invalid pricing code” are to be printed.
IPO (2.5)
Input Process Output
articlePrice PROMPT “enter article price” articlePrice
PricingCode GET articlePrice ✓ half discount ✓ half
✓ half PROMPT “enter pricing code” discountedPrice
GET PricingCode
Calculate discount ✓ half
PRINT articlePrice
PRINT Discount ✓ half
PRINT DiscountedPrice

Algorithm (8.5)
Calculate_Discount ✓ half
1. PROMPT “enter article price”
2. GET articlePrice ✓ half
3. PROMPT “enter pricing code”
4. GET PricingCode ✓ half
5. SET discount → 0 ✓ half
6. CASE OF PricingCode ✓
7. ‘H’: discount  articlePrice * 0.5 ✓ half
8. ‘F’: discount  articlePrice * 0.4 ✓ half
9. ‘T’: discount  articlePrice * 0.33 ✓ half
10. ‘Q’: discount  articlePrice * 0.25 ✓ half
11. ‘Z’: discount  0 ✓ half
12. Other: “Invalid pricing code, please re-enter a valid code” ✓ half
ENDCASE
13. SET discountedPrice  articlePrice – discount ✓ half
14. PRINT “The original price is” + articlePrice ✓ half
15. PRINT “The discount amount is” + discount ✓ half
16. PRINT “The discounted price is” + discountedPrice ✓ half
END ✓ half
Desk Check (4)
Line nr articlePrice PricingCode CASE discount discountedPrice
1,2 1500 ✓ half
3,4 F
5 0
6 True
8 ✓ half 600
13 900 ✓ half
14,15,16 PRINT PRINT PRINT
1,2 2150
3,4 Z✓ half
5 ✓ half 0 ✓ half
6 True
11 0
13 2150
14,15,16 PRINT PRINT PRINT
✓ half (All the PRINT) & ✓ half (All variable names)

2 An architect's fee is calculated as a percentage of the cost of a building. The


fee is made up as follows:

8% of the first R5000.00 of the cost of a building and


3% on the remainder if the remainder is less than or equal to R80000.00 or
2% on the remainder if the remainder is more than R80000.00

Design an algorithm that will accept the cost of a building and calculate and display
the architect's fee. Use nested IF statements. [15]
IPO (3)
Input Process Output
buildingCost PROMPT “Enter cost of the building” ✓ half architectFee
✓ half GET buildingCost ✓ half ✓ half
Calculate architectFee ✓ half
DISPLAY architectFee ✓ half

Algorithm (9)
Calculate_architect_fee ✓ half
1 SET architectFee  0 ✓ half
2 PROMPT “Enter cost of the building” ✓ half
3 GET buildingCost ✓ half
4 IF (buildingCost >= 0) AND (buildingCost <= 5000) THEN ✓
5 architectFee  5000 * 0.08 ✓
6 IF (buildingCost > 5000) AND (buildingCost <= 80000) THEN ✓
7 architectFee  (buildingCost – 5000) * 0.03 ✓
8 IF (buildingCost > 80000) THEN ✓
9 ✓ half architectFee  (buildingCost – 80000) * 0.02 ✓
ENDIF
ENDIF
ENDIF
10 DISPLAY “The cost of the building is” + buildingCost
11 DISPLAY “The fee for the architect is” + architectFee ✓ half
END ✓ half
Desk Check (3)

Line nr buildingCost IF architectFee


1 0
2,3 10000 ✓ half
6 ✓ half True
7 150 ✓ half
10, 11 DISPLAY DISPLAY
1 0
2,3 4000
4 True
5 ✓ half 320
10, 11 DISPLAY DISPLAY
✓ half (All DISPLAY) & ✓ half (All variable names)

NOTE: All your algorithms must show all steps clearly.

You might also like