0% found this document useful (0 votes)
143 views12 pages

12 Scenario Based Questions

Uploaded by

muzammilanjum237
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)
143 views12 pages

12 Scenario Based Questions

Uploaded by

muzammilanjum237
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/ 12

Scenario Based Question 1

The 1D array StudentName[]contains the names of students in a class.

The 2D array StudentMark[]contains the mark for each subject, for each student.

The position of each student’s data in the two arrays is the same, for example, the student in position 10
in StudentName[] and StudentMark[] are the same.

The variable ClassSize contains the number of students in the class.

The variable SubjectNo contains the number of subjects studied.

All students study the same number of subjects. The arrays and variables have already been set up and
the data stored. Student grades are awarded using the average mark, if an average mark is:

∙ greater than or equal to 70 then a distinction grade is awarded

∙ greater than or equal to 55 and less than 70 then a merit grade is awarded

∙ greater than or equal to 40 and less than 55 then a pass grade is awarded

∙ less than 40 then a fail grade is awarded.

Write a program that meets the following requirements:

∙ calculates the combined total mark for each student for all their subjects

∙ calculates the average mark for each student for all their subjects, rounded to the nearest
whole number

∙ outputs for each student

– name

– combined total mark

– average mark

– selected grade

∙ calculates, stores and outputs the number of distinctions, merits, passes and fails for the

whole class.

You must use pseudocode or program code.


Scenario Based Question 2
A parcel delivery service accepts parcels of a certain weight and size for delivery.

A customer can check whether the parcel is suitable for delivery by entering the weight and the
Dimension (length, width and height) of each parcel.

The parcel is accepted for delivery if the following rules apply:

∙ each Dimension (length, width and height) must be no more than 80 cm

∙ the sum of the three Dimensions must be no more than 200 cm

∙ the weight must be between 1 and 10 kg, inclusive.

The prices for a parcel are based on the weight as shown in the following table:

Write a program that meets the following requirements:

∙ requires a customer to input the weight and the Dimensions of the parcel to be checked, with a
suitable prompt

∙ validates each input so only a positive numerical value is allowed

∙ uses a function or procedure to check if the parcel has a valid weight and valid Dimensions:

– if valid, the price is calculated and output with a suitable message

– if not valid, outputs error message(s) clearly explaining the problem

∙ requires the customer to input whether they need to check a new parcel, with a suitable prompt:

– if they need to check a new parcel, the program repeats

– if they do not need to check a new parcel, the program ends.

You must use pseudocode or program code.


Scenario Based Question 3
A shop stores receipt numbers and amount spent on that receipt. This data is stored in the 2D array
Receipt.
The first index is the receipt number and the second index is the amount spent.
If a customer wants 1% of the total spent to be given to charity, they enter their receipt number into a
computer in the shop. The receipt number is validated to see if it has been used before.
If it has not been used before, the amount spent is retrieved. 1% of the amount spent and the choice of
charities are displayed. The customer inputs whether they want to donate to Charity1, Charity2 or
Charity3.
Write a program that meets the following requirements:
• requires the customer to input their receipt number, with a suitable prompt
• a receipt number of 9999 ends the program
• validates the receipt number by checking:
– the input is a four-digit number
– the receipt number already exists in the array Receipt
• if the receipt number is valid:
– calculate and output 1% of the amount spent
– output the three charity choices
– requires the customer to input their choice of charity
• if the receipt number is not valid, output one or more error messages that clearly identify the
problem
• the program repeats.
You must use pseudocode or program code.
Scenario Based Q4
The names of patients are stored in the one-dimensional (1D) array Patient[] of type string.

A separate two-dimensional (2D) array Readings[] stores the latest data recorded about each patient.
The array already contains the readings taken by a nurse for each patient:

• temperature measured to one decimal place

• pulse rate, a whole number.

Temperature readings should be in the range 31.6 to 37.2 inclusive.

Pulse readings should be in the range 55.0 to 100.0 inclusive.

The hospital number given to the patient is used for the index on both arrays, this is a value between 1
and 1000 inclusive.

When the data for a patient is checked a warning is given if any of the readings are out of range. If both
readings are out of range, then a severe warning is given. Write a procedure, using pseudocode or
program code, that meets the following requirements:

• takes the hospital number as a parameter

• checks if the number is valid

• outputs an error message and exits the procedure if the number is not valid

• if the hospital number is valid:

– output the patient’s name

– output ‘Normal readings’ if both the readings are within range

– output ‘Warning’ and the name of the reading e.g. ‘Pulse’ if one reading is out of range

– output ‘Severe warning’ and the names of the two readings ‘Pulse and temperature’ if both readings
are out of range

– exits the procedure. You must use pseudocode or program code and add comments to explain how
your code works.

You do not need to initialize the data in the arrays.


Scenario Based Q5

The one-dimensional (1D) array TeamName[] contains the names of teams in a sports league.

The two-dimensional (2D) array TeamPoints[] contains the points awarded for each match.

The position of each team’s data in the two arrays is the same. For example, the team stored at

index 10 in TeamName[] and TeamPoints[] is the same.

The variable LeagueSize contains the number of teams in the league. The variable MatchNo

contains the number of matches played. All teams have played the same number of matches.

The arrays and variables have already been set up and the data stored.

Each match can be played at home or away. Points are recorded for the match results of each

team with the following values:

• 3 – away win

• 2 – home win

• 1 – drawn match

• 0 – lost match.

Write a program that meets the following requirements:

• calculates the total points for all matches played for each team

• counts the total number of away wins, home wins, drawn matches and lost matches for each

team

• outputs for each team:

– name

– total points

– total number of away wins, home wins, drawn matches and lost matches

• finds and outputs the name of the team with the highest total points

• finds and outputs the name of the team with the lowest total points.

You do not need to declare any arrays, variables or constants; you may assume that this has already
been done.

All inputs and outputs must contain suitable messages.


Scenario Based Question 6
A one-dimensional (1D) array Days[] contains the names of the days of the week. A
two-dimensional (2D) array Readings[] is used to store 24 temperature readings, taken once
an hour, for each of the seven days of the week. A 1D array AverageTemp[] is used to store the
average temperature for each day of the week.
The position of any day’s data is the same in all three arrays. For example, if Wednesday is
in index 4 of Days[], Wednesday’s temperature readings are in index 4 of Readings[] and
Wednesday’s average temperature is in index 4 of AverageTemp[]
The temperature readings are in Celsius to one decimal place. Temperatures can only be from
–20.0°C to +50.0°C inclusive.
Write a program that meets the following requirements:
• input and validate the hourly temperatures for one week
• calculate and store the average temperature for each day of the week
• calculate the average temperature for the whole week
• convert all the average temperatures from Celsius to Fahrenheit by using the formula
Fahrenheit = Celsius * 9/5 + 32
• output the average temperature in Celsius and in Fahrenheit for each day
• output the overall average temperature in Celsius and in Fahrenheit for the whole week.
You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays, variables or constants; you may assume that this has
already been done.
All inputs and outputs must contain suitable messages.
All data output must be rounded to one decimal place.
You will need to initialise and populate the array Days[] at the start of the program.
Scenario Based Question 7
A two-dimensional (2D) array Account[] contains account holders’ names and passwords for a
banking program.
A 2D array AccDetails[] has three columns containing the following details:
• column one stores the balance – the amount of money in the account, for example 250.00
• column two stores the overdraft limit – the maximum total amount an account holder can
borrow from the bank after the account balance reaches 0.00, for example 100.00
• column three stores the withdrawal limit – the amount of money that can be withdrawn at one
time, for example 200.00
The amount of money in a bank account can be negative (overdrawn) but not by more than the
overdraft limit.
For example, an account with an overdraft limit of 100.00 must have a balance that is greater than
or equal to –100.00
Suitable error messages must be displayed if a withdrawal cannot take place, for example if the
overdraft limit or the size of withdrawal is exceeded.
The bank account ID gives the index of each account holder’s data held in the two arrays.
For example, account ID 20’s details would be held in:
Account[20,1] and Account[20,2]
AccDetails[20,1] AccDetails[20,2] and AccDetails[20,3]
The variable Size contains the number of accounts.
The arrays and variable Size have already been set up and the data stored.
Write a program that meets the following requirements:
• checks the account ID exists and the name and password entered by the account holder
match the name and password stored in Account[] before any action can take place
• displays a menu showing the four actions available for the account holder to choose from:
1. display balance
2. withdraw money
3. deposit money
4. exit
• allows an action to be chosen and completed. Each action is completed by a procedure
with a parameter of the account ID.
You must use pseudocode or program code and add comments to explain how your code works.
All inputs and outputs must contain suitable messages.
You only need to declare any local arrays and local variables that you use.
You do not need to declare and initialise the data in the global arrays Account[] and
AccDetails[] and the variable Size
Scenario Based Question 8
The hotel has nine rooms that are numbered from room 1 to room 9.

The number of people currently staying in each room is stored in an array with the identifier room.

The index of room represents the room number.

Array room

Index 1 2 3 4 5 6 8 8 9
Data 2 1 3 2 1 0 0 4 1

Customers at a hotel can stay between 1 and 5 (inclusive) nights and can choose between a basic room
or a premium room.

(a) When a new booking is recorded, the following details are entered into a program
a. Firstname and surname of each customer
b. Type of the Room
c. Number of Nights Stay

To validate the values. The following criteria are checked:

(b) firstName and surname are not empty


(c) room is either “basic” or “premium”
(d) nights is between 1 and 5 (inclusive).
(e) If any invalid data is found “NOT ALLOWED” is displayed. If all data is valid “ALLOWED” is
displayed.
Write a program to:
• Input Firstname and Surname of each customer, Type of the Room, Number of Nights
Stay(include validation checks)
• Create a function, newPrice(), that takes the number of nights and the type of room
as parameters, calculates and returns the price to pay according to the following
policy:
 A Basic room costs £60 each night.
 A Premium room costs £80 each night.
• Count total number of people are currently staying in the hotel.
Scenario Based Question 9
A one-dimensional (1D) array Days[] contains the names of the days of the week. A
two-dimensional (2D) array Readings[] is used to store 24 temperature readings, taken once
an hour, for each of the seven days of the week. A 1D array AverageTemp[] is used to store the
average temperature for each day of the week.
The position of any day’s data is the same in all three arrays. For example, if Wednesday is
in index 4 of Days[], Wednesday’s temperature readings are in index 4 of Readings[] and
Wednesday’s average temperature is in index 4 of AverageTemp[]
The temperature readings are in Celsius to one decimal place. Temperatures can only be from
–20.0°C to +50.0°C inclusive.
Write a program that meets the following requirements:
• input and validate the hourly temperatures for one week
• calculate and store the average temperature for each day of the week
• calculate the average temperature for the whole week
• convert all the average temperatures from Celsius to Fahrenheit by using the formula
Fahrenheit = Celsius * 9/5 + 32
• output the average temperature in Celsius and in Fahrenheit for each day
• output the overall average temperature in Celsius and in Fahrenheit for the whole week.
You must use pseudocode or program code and add comments to explain how your code works.
You do not need to declare any arrays, variables or constants; you may assume that this has
already been done.
All inputs and outputs must contain suitable messages.
All data output must be rounded to one decimal place.
You will need to initialise and populate the array Days[] at the start of the program.
Scenario Based Question 10

A two-dimensional (2D) array Account[] contains account holders’ names and passwords for a

banking program. A 2D array AccDetails[] has three columns containing the following details:

• column one stores the balance – the amount of money in the account, for example 250.00

• column two stores the overdraft limit – the maximum total amount an account holder can borrow
from the bank after the account balance reaches 0.00, for example 100.00

• column three stores the withdrawal limit – the amount of money that can be withdrawn at one time,
for example 200.00

The amount of money in a bank account can be negative (overdrawn) but not by more than the
overdraft limit. For example, an account with an overdraft limit of 100.00 must have a balance that is
greater than or equal to –100.00

Suitable error messages must be displayed if a withdrawal cannot take place, for example if the
overdraft limit or the size of withdrawal is exceeded.

The bank account ID gives the index of each account holder’s data held in the two arrays. For example,
account ID 20’s details would be held in:

Account[20,1] and Account[20,2]


AccDetails[20,1] AccDetails[20,2] and AccDetails[20,3]
The variable Size contains the number of accounts.
The arrays and variable Size have already been set up and the data stored.
Write a program that meets the following requirements:
• checks the account ID exists and the name and password entered by the account holder
match the name and password stored in Account[] before any action can take place
• displays a menu showing the four actions available for the account holder to choose from:
1. display balance
2. withdraw money
3. deposit money
4. exit
• allows an action to be chosen and completed. Each action is completed by a procedure with a
parameter of the account ID.
You must use pseudocode or program code and add comments to explain how your code works. All
inputs and outputs must contain suitable messages.
Scenario Based Question 11
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 index 4
of Customers[] corresponds to the data in index 4 of Quotations[]. The wood choices available are:

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
the calculated price of the wood required
• 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.
Scenario Based Question 12
A weather station takes temperature readings once an hour for a week. These temperatures are stored
in a two-dimensional (2D) array Temperatures[]

Each column contains 24 readings for a single day. The first temperature is recorded at 00:00 and the
final temperature at 23:00. There are seven columns, one for each day of the week, starting with
Monday and ending with Sunday.

The variables MaxDay, MinDay and AvDay are used to store the maximum, minimum, and average
temperatures for a day. The variables MaxWeek, MinWeek and AvWeek are used to store the
maximum, minimum, and average temperatures for the week.

The array has already been set up and the data stored. Write a program that meets the following
requirements:
• finds the maximum and minimum temperatures for each day
• calculates the average temperature for each day
• outputs for each day:
– name of the day, for example Monday
– maximum temperature
– minimum temperature
– average temperature
• finds the maximum and minimum temperatures for the week
• calculates the average temperature for the week
• outputs:
– maximum temperature for the week
– minimum temperature for the week
– average temperature for the week.
All temperatures output must be rounded to two decimal places.

You must use pseudocode or program code and add comments to explain how your code works.

All inputs and outputs must contain suitable messages.

You do not need to declare any arrays or variables; you may assume that this has already been

done.

You do not need to initialise the data in the array Temperatures[]

You might also like