Sie sind auf Seite 1von 2

Task 2 Solution (Pseudocode)

DECLARE shape, color: STRING


DECLARE choice, depth, diameter: INTEGER
DECLARE volume, totalvolume, price: FLOAT
DECLARE batch_size: INTEGER
CONST grey_price, pi, setupcost: FLOAT

shape “ ”
color “ “
choice 0
depth 0
diameter 0
batch_size 0
volume 0.0
totalvolume 0.0
price 0.0
grey_price 0.05
pi 3.142
setupcost 5

INPUT “Enter total slabs to buy. 20 to 100”, slabs


IF slabs < 20 OR slabs > 100 THEN
PRINT “Error. Slabs should be between 20 and 100”
ELSE
ans slabs MOD 20
IF ans <> 0 THEN
batch_size (slabs – ans) + 20
ELSE
batch_size slabs
END IF
END IF

INPUT “Enter Shape of slabs. Square, rectangle or round”, shape

IF shape = “square” THEN


INPUT “Select choice for square sizes. 1 for 600x600 2 for 450x450”, choice
CASE choice OF
CASE 1: volume = 600*600
CASE 2: volume = 450*450

Sir Mym (0332-3033505) Sir Bandeshah (0333-2076121)


OTHERWISE: OUTPUT “Wrong Choice”
ENDCASE

ELSE IF shape = “rectangle” THEN


INPUT “Select choice for rectangle sizes. 1 for 600x700 2 for 600x450”, choice
CASE choice OF
CASE 1: volume = 600*700
CASE 2: volume = 600*450
OTHERWISE: OUTPUT “Wrong Choice”
ENDCASE

ELSE IF shape = “round” THEN


INPUT “Select choice for circle diameter. 1 for 300 2 for 450”, choice
CASE choice OF
CASE 1: volume pi * (300 / 2) ^ 2
CASE 2: volume pi * (450 / 2) ^ 2
OTHERWISE: OUTPUT “Wrong Choice”
ENDCASE

totalvolume  volume * batch_size

CASE color OF
CASE “grey”: price (totalvolume / 100000) * grey_price
CASE “red”: price (totalvolume / 100000) * grey_price * 0.1
CASE “green”: price (totalvolume / 100000) * grey_price * 0.1
CASE “custom”: price ((totalvolume / 100000) * grey_price * 0.15) + setupcost
OTHERWISE: OUTPUT “Wrong Color Selected”
ENDCASE

PRINT “The total slabs to be produced are”, batch_size


PRINT “The total price of the order is”, price

Sir Mym (0332-3033505) Sir Bandeshah (0333-2076121)

Das könnte Ihnen auch gefallen