Note AcademyNote Academy

Computer Science · Oct / Nov 2023 · Paper 22 · Question 11

0478

As printed in the paper

The question as text

A wood flooring company stores the names of up to 100 customers in a one‑dimensional (1D) array Customers[]. A two‑dimensional (2D) array Quotations[] stores details of each customer’s quotation: • length of room (one decimal place) • width of room (one decimal place) • area of wood required (rounded up to next whole number) • choice of wood index (whole number) • price of wood required in dollars (two decimal places). The floor measurements (room length and room width) are taken in metres. All floors are rectangles and room measurements must be between 1.5 and 10.0 inclusive. The index of any customer’s data is the same in both arrays. For example, a customer named in in Customers[] corresponds to the data in index 4 of Quotations[] The wood choices available are: Index Wood type Price per square metre ($) 1 Laminate 29.99 2 Pine 39.99 3 Oak 54.99 The data are stored in two 1D arrays named WoodType[] and Price[]. The index of the wood type and price in their arrays share the same index number. Write a program that meets the following requirements: • input a new customer’s name, room length and room width • check that each measurement is valid • output an error message and require the measurement to be re‑entered until it is valid • calculate the area of the room by multiplying together the length of the room and the width of the room • input the choice of wood and find its price per square metre • calculate the price of the wood needed • store all data in the relevant array • output the customer’s quotation to include: the name of the customer, the choice of wood and th • continue to accept the next customer. You must use pseudocode or program code and add comments to explain how your code works. You do not need to declare any arrays or variables; you may assume that this has already been done. You will need to initialise WoodType[] and Price[] All inputs and outputs must contain suitable messages.

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme

Requirements may be met using a suitable built-in function from the programming language used (Python, VB.NET or Java)

Tables for AO2 and AO3 are used to award a mark in a suitable band using a best fit approach.

Marks are available for:

AO2 (maximum 9 marks)
AO3 (maximum 6 marks)

Data Structures required with names as given in the scenario

The names underlined must be used as they are provided in the scenario: Arrays or lists WoodType[], Price[], Customers[], Quotations[] Requirements (techniques)

R1 Input and store customer name, room length and width, with validation of input for room dimensions, including error message and repeated input (Input with prompts, range check and iteration).

R2 Initialise wood arrays. Calculate room area, select and store wood required. Determine cost of wood type and calculate price of wood to purchase. Round and store all data to relevant array (array initialisation, rounding, data retrieval from array, calculation and storage of results). R3 Output full details: name of customer, choice of wood and quotation price with appropriate messages. Program continues for next customer (Output with messages, iteration of whole program).

Example 15-mark answer in pseudocode

// declarations not required in the answer

// initial population of WoodType[] and Price[] arrays // input and loops are also acceptable

WoodType[1] ← "Laminate"

WoodType[2] ← "Pine"

WoodType[3] ← "Oak"

Price[1] ← 29.99

Price[2] ← 39.99

Price[3] ← 54.99

// initialises starting customer in sales arrays

CurrentCustomer ← 1

// to allow program to continue to next customer

Cont ← TRUE

WHILE Cont DO

// input customer name

OUTPUT "Input the customer’s name "

INPUT Customers[CurrentCustomer]

// input of room dimensions with validation

OUTPUT "What is the length of your room? "

INPUT RoomLength

// validate RoomLength

WHILE RoomLength < 1.5 OR RoomLength > 10.0

OUTPUT "The measurement must be in the range 1.5 to 10.0 inclusive, please try again " INPUT RoomLength

ENDWHILE

OUTPUT "What is the width of your room? "

INPUT RoomWidth

// validate RoomWidth

WHILE RoomWidth < 1.5 OR RoomWidth > 10.0

OUTPUT "The measurement must be in the range 1.5 to 10.0 inclusive, please try again " INPUT RoomWidth

ENDWHILE

RoomArea ← ROUND(RoomLength, 1) * ROUND(RoomWidth, 1)

RoomArea ← ROUND (RoomArea + 0.5, 0)

// show the wood available and prices

OUTPUT "the wood choices available are:"

OUTPUT "Number Wood Type Price($)"

FOR Count ← 1 TO 3

OUTPUT Count, " ", WoodType[Count], " ",

Price[Count]

Next Count

// input wood choice

OUTPUT "Input a number from 1 to 3 "

INPUT WoodChoice

// validate wood choice

WHILE WoodChoice < 1 OR WoodChoice > 3

OUTPUT "Your input is out of range, please try again "

INPUT WoodChoice

ENDWHILE

// to calculate the total cost of the wood

WoodCost ← RoomArea * Price[WoodChoice]

// to store the relevant data in Quotations[]

Quotations[CurrentCustomer, 1] ← RoomLength

Quotations[CurrentCustomer, 2] ← RoomWidth

Quotations[CurrentCustomer, 3] ← RoomArea

Quotations[CurrentCustomer, 4] ← WoodChoice

Quotations[CurrentCustomer, 5] ← WoodCost

// final output of quotation

OUTPUT "Customer name: ", Customers[CurrentCustomer] OUTPUT "The wood you have chosen is: ",

WoodType[WoodChoice]

OUTPUT "Your total price is: ",

Quotations[CurrentCustomer,5]

// ready for next customer

CurrentCustomer ← CurrentCustomer + 1

// resets CurrentCustomer to beginning of array when array

// limit reached

IF CurrentCustomer > 100

THEN

CurrentCustomer ← 1

ENDIF

ENDWHILE

Marking Instructions in italics

AO2:

Apply knowledge and understanding of the principles and concepts of computer science to a given context, including the analysis and design of computational or programming problems

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.