Sei sulla pagina 1di 4

SCHOOL: NU VISION HIGH SCHOOL RWANDA / CAMBRIDGE IGCSE

Teacher: JULES TUBEBAMWE Email: julesbamwe7@gmail.com Phone: +250781423227

Subject: COMPUTER SCIENCE


PRE RELEASE MATERIALS SOLUTION OF TASKS
The following is an identifier table explaining different variables used.
Identifier Name Data Type Explanation
SColour STRING Stores the colour of a slab.
SDepth INTEGER Stores the depth of a slab.
SShape STRING Store the shape type of a slab
between Square, Rectangular or Round
UPriceGrey FLOAT/DOUBLE /REAL Constant of 0.05$ for storing the
initial price per volume of 100 000
mm3 or Unit price
ShapeDimension INTEGER Stores the dimension or size of a
selected shape.
UVolume FLOAT/DOUBLE /REAL Stores the volume of a single slab.
UPrice FLOAT/DOUBLE /REAL Stores the price of a single slab
calculated from the volume.
TotalPriceGrey FLOAT/DOUBLE /REAL Store the total price of 20 grey
slabs that form a batch.
TotalPriceRG FLOAT/DOUBLE /REAL Store the total price of 20 red or
green slabs that form a batch.
TotalPriceCust FLOAT/DOUBLE /REAL Store the total price of 20 customer
coloured slabs that form a batch.
NumberOfSlabs INTEGER Stores the number of slabs entered
by the user when making an order.
Remainder INTEGER Stores the remainder of the division
of NumberOfSlabs by 20 to make sure
whether or not the order made by the
user is a multiple of 20. Notice
that a batch contains 20 slabs.
NumberOfBatch INTEGER Stores the number of batches to be
delivered to the customer after
making the order. Calculated from
NumberOfSlabs/20. Notice that a
batch contains 20 slabs.
OrderPrice FLOAT/DOUBLE /REAL Stores the price that should be paid
by the customer for the delivery;
calculated from the number of
batches and the total price of 20
slabs.
GradeOfConcrete STRING Stores the Grade of Concrete which
can either be basic or best.

TASK 1
INPUT “Enter slab Colour: ”,SColour
INPUT “Enter Depth of Slab: ”,SDepth
WHILE (SDepth <>45) OR (SDepth<>38) DO
INPUT “Enter Depth of Slab: ”,SDepth
ENDWHILE
INPUT “Enter Shape Type: Square or Rectangular or Round: ”,SShape
UPriceGrey 0.05
CASE SShape OF
“Square”: INPUT “Enter Square size: 600 or 450 :”, ShapeDimension
WHILE (ShapeDimension<>600) OR (ShapeDimension<>450) DO
INPUT “Enter Square size: 600 or 450 :”, ShapeDimension
ENDWHILE
UVolume ShapeDimension* ShapeDimension*SDepth
UPrice (UVolume/100000)* UPriceGrey
TotalPriceGrey UPrice*20
“Rectangular”: INPUT “Enter Rectangle height: 700 or 450 :”, ShapeDimension
WHILE (ShapeDimension<>700) OR (ShapeDimension<>450) DO
INPUT “Enter Rectangle height: 700 or 450 : ”, ShapeDimension
ENDWHILE
UVolume 600* ShapeDimension*SDepth
UPrice (UVolume/100000)* UPriceGrey
TotalPriceGrey UPrice*20
“Round”: INPUT “Enter Diameter: 300 or 450 :”, ShapeDimension
WHILE (ShapeDimension<>300) OR (ShapeDimension<>450) DO
INPUT “Enter Diameter: 300 or 450: ”, ShapeDimension
ENDWHILE
UVolume ShapeDimension* ShapeDimension*3.14*SDepth
UPrice (UVolume/100000)* UPriceGrey
TotalPriceGrey UPrice*20
OTHERWISE: OUTPUT “INVALID SHAPE TYPE”
ENDCASE
TotalPriceRG TotalPriceGrey+( TotalPriceGrey*10/100)
TotalPriceCust TotalPriceGrey+( TotalPriceGrey*15/100)
//OUTPUT SLAB DETAILS
OUTPUT “CHOSEN COLOUR: ”,SColour
OUTPUT “DEPTH OF SLAB: ”,SDepth
OUTPUT “SHAPE TYPE: ”,SShape
OUTPUT “SHAPE DIMENSION: ”,ShapeDimension
IF (SColour=”Grey”)
THEN OUTPUT “PRICE OF A BATCH OF 20 SLABS: ”,TotalPriceGrey
ELSE
IF (SColour=”Red”) OR (SColour=”Green”)
THEN OUTPUT “PRICE OF A BATCH OF 20 SLABS: ”,TotalPriceRG
ELSE OUTPUT “PRICE OF A BATCH OF 20 SLABS: ”,TotalPriceCust
ENDIF
ENDIF

TASK 2
INPUT NumberOfSlabs
WHILE (NumberOfSlabs<20) OR (NumberOfSlabs>100) DO
INPUT NumberOfSlabs
ENDWHILE
Remainder NumberOfSlabs MOD 20
IF (Remainder<>0)
THEN
NumberOfSlabs NumberOfSlabs+(20-Remainder)
ENDIF
NumberOfBatch NumberOfSlabs/20
OUTPUT “NUMBER OF SLABS: ”, NumberOfSlabs
OUTPUT “NUMBER OF BATCH: ”, NumberOfBatch
IF (SColour=”Grey”)
THEN
OrderPrice NumberOfBatch*TotalPriceGrey
ELSE
IF (SColour=”Red”) OR (SColour=”Green”)
THEN
OrderPrice NumberOfBatch*TotalPriceRG
ELSE
OrderPrice NumberOfBatch*TotalPriceCust
ENDIF
ENDIF
OUTPUT “ORDER PRICE: ”,OrderPrice

TASK 3
INPUT UPriceGrey
INPUT GradeOfConcrete
WHILE (GradeOfConcrete<>”basic”) OR (GradeOfConcrete<>”best”)
INPUT GradeOfConcrete
ENDWHILE
IF (GradeOfConcrete=”best”)
THEN
UPriceGrey UPriceGrey/0.965
ENDIF

Potrebbero piacerti anche