100% found this document useful (3 votes)
2K views

15 Mark Questions

The document provides pseudocode to calculate bonuses/discounts for employees, products, and customers based on salary/price data stored in 1D and 2D arrays. The pseudocode calculates total values, averages, bonuses/discounts for each entry, outputs the results, and calculates overall totals. It uses meaningful variable names, loops through the arrays, performs conditional checks to determine bonuses/discounts, and calculates running sums.

Uploaded by

BigBoi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
2K views

15 Mark Questions

The document provides pseudocode to calculate bonuses/discounts for employees, products, and customers based on salary/price data stored in 1D and 2D arrays. The pseudocode calculates total values, averages, bonuses/discounts for each entry, outputs the results, and calculates overall totals. It uses meaningful variable names, loops through the arrays, performs conditional checks to determine bonuses/discounts, and calculates running sums.

Uploaded by

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

The 1D array EmployeeID[] contains the identification numbers of employees in a

company. The 2D array EmployeeSalary[] contains the salary for each employee
in different departments, for each employee. The position of each employee's
data in the two arrays is the same, for example, the employee in position 6 in
EmployeeID[] and EmployeeSalary[] is the same.

The variable EmployeeNo contains the number of employees in the company. The
variable DepartmentNo contains the number of departments in the company. All
employees work in the same number of departments.

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

Employees are awarded a bonus based on their average salary.

Average salary Bonus awarded greater than or equal to $75,000 $1,000 greater
than or equal to $50,000 and less than $75,000 $500 less than $50,000 no bonus

Write a program that meets the following requirements:

● calculates the total salary for each employee in all their


departments
● calculates the average salary for each employee in all their
departments, rounded to the nearest whole number
● outputs for each employee:
● identification number
● total salary
● average salary
● bonus awarded
● calculates, stores and outputs the total bonus awarded to all
employees in the company.

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 array.

// meaningful identifier names and appropriate data structures (variables, constants and the

// given arrays) to store all the data required

DECLARE TotalSalary : ARRAY[1:50] OF INTEGER


DECLARE AverageSalary : ARRAY[1:50] OF INTEGER

DECLARE Bonus : ARRAY[1:50] OF INTEGER

DECLARE DepartmentCounter : INTEGER

DECLARE EmployeeCounter : INTEGER

DECLARE TotalBonus : INTEGER

CONSTANT Bonus1000 = 1000

CONSTANT Bonus500 = 500

CONSTANT Salary75000 = 75000

CONSTANT Salary50000 = 50000

// initialisation processes for this scenario, initialising the running totals used for

// bonuses and combined salaries

TotalBonus ← 0

FOR EmployeeCounter ← 1 to EmployeeNo

TotalSalary[EmployeeCounter] ← 0

FOR DepartmentCounter ← 1 to DepartmentNo

TotalSalary[EmployeeCounter] = TotalSalary[EmployeeCounter] +
EmployeeSalary[EmployeeCounter, DepartmentCounter]

NEXT DepartmentCounter

AverageSalary[EmployeeCounter] =
ROUND(TotalSalary[EmployeeCounter]/DepartmentNo)

// calculate and output employee's information

OUTPUT "Employee ID: " + EmployeeID[EmployeeCounter]

OUTPUT "Total salary: $" + TotalSalary[EmployeeCounter]

OUTPUT "Average salary: $" + AverageSalary[EmployeeCounter]


IF AverageSalary[EmployeeCounter] >= Salary75000

Bonus[EmployeeCounter] = Bonus1000

OUTPUT "Bonus awarded: $" + Bonus[EmployeeCounter]

TotalBonus = TotalBonus + Bonus[EmployeeCounter]

ELSE IF AverageSalary[EmployeeCounter] >= Salary50000

Bonus[EmployeeCounter] = Bonus500

OUTPUT "Bonus awarded: $" + Bonus[EmployeeCounter]

TotalBonus = TotalBonus + Bonus[EmployeeCounter]

ELSE

OUTPUT "No bonus awarded"

END IF

NEXT EmployeeCounter

// output the total bonus awarded to all employees

OUTPUT "Total bonus awarded: $" + TotalBonus

The 1D array ProductID[] contains the identification numbers of products in a store.


The 2D array ProductPrice[] contains the price for each product in different colors, for
each product. The position of each product's data in the two arrays is the same, for
example, the product in position 3 in ProductID[] and ProductPrice[] is the same.

The variable ProductNo contains the number of products in the store. The variable
ColorNo contains the number of colors available for each product. All products have
the same number of colors available.

The arrays and variables have already been set up and the data stored.
A discount is applied to the products based on their average price.

Average price Discount applied greater than or equal to 50 10% greater than or
equal to 30 and less than 50 5% less than 30 no discount

Write a program that meets the following requirements:

● calculates the combined total price for each product in all its colors
● calculates the average price for each product in all its colors, rounded
to the nearest whole number
● outputs for each product:
● identification number
● combined total price
● average price
● discount applied
● calculates, stores and outputs the total discount applied to all products
in the store.

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 array

// meaningful identifier names and appropriate data structures (variables, constants and the

// given arrays) to store all the data required

DECLARE TotalPrice : ARRAY[1:50] OF INTEGER

DECLARE AveragePrice : ARRAY[1:50] OF INTEGER

DECLARE ColorCounter : INTEGER

DECLARE ProductCounter : INTEGER

DECLARE TotalDiscount : INTEGER

CONSTANT Discount10 = 10

CONSTANT Discount5 = 5

// initialisation processes for this scenario, initialising the running totals used for

// discount and combined totals

TotalDiscount ← 0
FOR ProductCounter ← 1 to ProductNo

TotalPrice[ProductCounter] ← 0

FOR ColorCounter ← 1 to ColorNo

TotalPrice[ProductCounter] = TotalPrice[ProductCounter] + ProductPrice[ProductCounter,


ColorCounter]

NEXT ColorCounter

AveragePrice[ProductCounter] = ROUND(TotalPrice[ProductCounter]/ColorNo)

// calculate and output product's information

OUTPUT "Product ID: " + ProductID[ProductCounter]

OUTPUT "Combined total price: " + TotalPrice[ProductCounter]

OUTPUT "Average price: " + AveragePrice[ProductCounter]

// calculate and output product's discount

IF AveragePrice[ProductCounter] >= 50

OUTPUT "Discount applied: 10%"

TotalDiscount = TotalDiscount + TotalPrice[ProductCounter] * Discount10 / 100

ELSE IF AveragePrice[ProductCounter] >= 30 AND AveragePrice[ProductCounter] < 50

OUTPUT "Discount applied: 5%"

TotalDiscount = TotalDiscount + TotalPrice[ProductCounter] * Discount5 / 100

ELSE

OUTPUT "No discount applied"

END IF

NEXT ProductCounter

// output the total discount applied to all products in the store

OUTPUT "Total discount applied: " + TotalDiscount


The 1D array CustomerID[] contains the identification numbers of customers in a
store. The 2D array CustomerPurchase[] contains the amount of money spent by
each customer on each purchase, for each customer. The position of each
customer's data in the two arrays is the same, for example, the customer in position
2 in CustomerID[] and CustomerPurchase[] is the same.

The variable CustomerNo contains the number of customers in the store. The
variable PurchaseNo contains the number of purchases made by each customer. All
customers make the same number of purchases.

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

Customers are awarded a discount on their next purchase based on the total amount
of money they spent.

Total spent Discount applied greater than or equal to 100 10% greater than or equal
to 50 and less than 100 5% less than 50 no discount

Write a program that meets the following requirements:

● calculates the total amount of money spent by each customer on all


their purchases
● outputs for each customer:
● identification number
● total amount spent
● discount applied on the next purchase
● calculates, stores and outputs the total discount applied to all
customers in the store.

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 array.

Solution

// meaningful identifier names and appropriate data structures (variables, constants and the

// given arrays) to store all the data required

DECLARE TotalSpent : ARRAY[1:50] OF INTEGER

DECLARE Discount : ARRAY[1:50] OF INTEGER

DECLARE PurchaseCounter : INTEGER

DECLARE CustomerCounter : INTEGER

DECLARE TotalDiscount : INTEGER

CONSTANT Discount10 = 10

CONSTANT Discount5 = 5

// initialisation processes for this scenario, initialising the running totals used for

// discount and combined totals

TotalDiscount ← 0

FOR CustomerCounter ← 1 to CustomerNo

TotalSpent[CustomerCounter] ← 0

FOR PurchaseCounter ← 1 to PurchaseNo

TotalSpent[CustomerCounter] = TotalSpent[CustomerCounter] +
CustomerPurchase[CustomerCounter, PurchaseCounter]

NEXT PurchaseCounter

// calculate and output customer's information


OUTPUT "Customer ID: " + CustomerID[CustomerCounter]

OUTPUT "Total amount spent: " + TotalSpent[CustomerCounter]

// calculate and output customer's discount

IF TotalSpent[CustomerCounter] >= 100

OUTPUT "Discount applied on next purchase: 10%"

Discount[CustomerCounter] = Discount10

TotalDiscount = TotalDiscount + TotalSpent[CustomerCounter] * Discount10 / 100

ELSE IF TotalSpent[CustomerCounter] >= 50 AND TotalSpent[CustomerCounter] < 100

OUTPUT "Discount applied on next purchase: 5%"

Discount[CustomerCounter] = Discount5

TotalDiscount = TotalDiscount + TotalSpent[CustomerCounter] * Discount5 / 100

ELSE

OUTPUT "No discount applied on next purchase"

Discount[CustomerCounter] = 0

END IF

NEXT CustomerCounter

//
The 1D array StudentID[] contains the identification numbers of students in a class.
The 2D array StudentAssignment[] contains the score for each assignment, for each
student. The position of each student's data in the two arrays is the same, for
example, the student in position 4 in StudentID[] and StudentAssignment[] is the
same.

The variable StudentNo contains the number of students in the class. The variable
AssignmentNo contains the number of assignments given to each student. All
students receive the same number of assignments.

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

Students are awarded a bonus mark based on their average score.

Average score Bonus mark awarded greater than or equal to 80 2 greater than or
equal to 60 and less than 80 1 less than 60 0

Write a program that meets the following requirements:

● calculates the total score for each student on all their assignments
● calculates the average score for each student on all their assignments,
rounded to the nearest whole number
● outputs for each student:
● identification number
● total score
● average score
● bonus mark awarded
● calculates, stores and outputs the total bonus marks awarded to all
students in the class.

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 array.

// meaningful identifier names and appropriate data structures (variables, constants and the

// given arrays) to store all the data required

DECLARE TotalScore : ARRAY[1:50] OF INTEGER

DECLARE AverageScore : ARRAY[1:50] OF INTEGER

DECLARE BonusMark : ARRAY[1:50] OF INTEGER

DECLARE AssignmentCounter : INTEGER

DECLARE StudentCounter : INTEGER

DECLARE TotalBonusMark : INTEGER


The 1D array DriverID[] contains the identification numbers of drivers in a city. The
2D array DriverSpeed[] contains the speed of each driver on each road, for each
driver. The position of each driver's data in the two arrays is the same, for example,
the driver in position 3 in DriverID[] and DriverSpeed[] is the same.

The variable DriverNo contains the number of drivers in the city. The variable RoadNo
contains the number of roads on which each driver was monitored. All drivers were
monitored on the same number of roads.

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

Drivers are fined based on their maximum speed on any road.

Maximum speed Fine applied greater than or equal to 120 100 greater than or equal
to 100 and less than 120 50 less than 100 no fine

Write a program that meets the following requirements:

● calculates the maximum speed of each driver on all roads


● outputs for each driver:
● identification number
● maximum speed
● fine applied
● calculates, stores and outputs the total fines applied to all drivers in the
city.

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 array

Question 3

// meaningful identifier names and appropriate data structures (variables, constants and the

// given arrays) to store all the data required

DECLARE Speed : ARRAY[1:50] OF INTEGER

DECLARE Fine : ARRAY[1:50] OF INTEGER

DECLARE VehicleCounter : INTEGER

DECLARE TotalFine : INTEGER


CONSTANT Fine10 = 10

CONSTANT Fine5 = 5

// initialisation processes for this scenario, initialising the running totals used for

// fines

TotalFine ← 0

FOR VehicleCounter ← 1 to VehicleNo

// calculate and output vehicle's speed and fine

OUTPUT "Vehicle " + VehicleCounter + " speed: " + Speed[VehicleCounter] + " mph"

IF Speed[VehicleCounter] > SpeedLimit

Fine[VehicleCounter] = IF Speed[VehicleCounter] > SpeedLimit + 10 THEN Fine10 ELSE


Fine5

OUTPUT "Fine applied: $" + Fine[VehicleCounter]

TotalFine = TotalFine + Fine[VehicleCounter]

ELSE

OUTPUT "No fine applied"

END IF

NEXT VehicleCounter

// output the total fine applied to all vehicles

OUTPUT "Total fine applied: $" + TotalFine

The 1D array CustomerID[] contains the identification numbers of customers in a


store. The 2D array CustomerOrder[] contains the number of items ordered for each
customer in different categories, for each customer. The position of each customer's
data in the two arrays is the same, for example, the customer in position 7 in
CustomerID[] and CustomerOrder[] is the same.

The variable CustomerNo contains the number of customers in the store. The variable
CategoryNo contains the number of categories of items in the store. All customers
order items from the same number of categories.

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

Customers are awarded a discount based on the total number of items they ordered.

Total number of items ordered Discount applied


greater than or equal to 50 10%
greater than or equal to 30 and less than 50 5%

less than 30 no discount

Write a program that meets the following requirements:

● calculates the total number of items ordered for each customer in all
categories
● outputs for each customer:
○ identification number
○ total number of items ordered
○ discount applied
● calculates, stores and outputs the total discount applied to all customers in
the store.

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 array

// meaningful identifier names and appropriate data structures (variables, constants and the
// given arrays) to store all the data required
DECLARE TotalItems : ARRAY[1:50] OF INTEGER
DECLARE Discount : ARRAY[1:50] OF INTEGER
DECLARE CategoryCounter : INTEGER
DECLARE CustomerCounter : INTEGER
DECLARE TotalDiscount : INTEGER

CONSTANT Discount10 = 10
CONSTANT Discount5 = 5

// initialisation processes for this scenario, initialising the running totals used for
// discounts
TotalDiscount ← 0

FOR CustomerCounter ← 1 to CustomerNo


TotalItems[CustomerCounter] ← 0
FOR CategoryCounter ← 1 to CategoryNo
TotalItems[CustomerCounter] = TotalItems[CustomerCounter] +
CustomerOrder[CustomerCounter, CategoryCounter]
NEXT CategoryCounter

// calculate and output customer's information


OUTPUT "Customer ID: " + CustomerID[CustomerCounter]
OUTPUT "Total items ordered: " + TotalItems[CustomerCounter]
IF TotalItems[CustomerCounter] >= 50
Discount[CustomerCounter] = Discount10
OUTPUT "Discount applied: " + Discount[CustomerCounter] + "%"
Question 7

The 1D array CountryID[] contains the identification numbers of countries in the world.
The 2D array CountryPopulation[] contains the population for each country in different
age groups, for each country. The position of each country's data in the two arrays is
the same, for example, the country in position 9 in CountryID[] and CountryPopulation[] is
the same.

The variable CountryNo contains the number of countries in the world. The variable
AgeGroupNo contains the number of age groups in each country. All countries have
the same number of age groups.

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

Countries are ranked based on the total population in each age group.

Write a program that meets the following requirements:

● calculates the total population for each country in all age groups
● outputs for each country:
○ identification number
○ total population
○ rank
● calculates, stores and outputs the average rank of all countries in the world.

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 array.

// meaningful identifier names and appropriate data structures (variables, constants and the
// given arrays) to store all the data required
DECLARE TotalPopulation : ARRAY[1:50] OF INTEGER
DECLARE Rank : ARRAY[1:50] OF INTEGER
DECLARE AgeGroupCounter : INTEGER
DECLARE CountryCounter : INTEGER
DECLARE TotalRank : INTEGER
// initialisation processes for this scenario, initialising the running totals used for
// ranking
TotalRank ← 0

FOR CountryCounter ← 1 to CountryNo


TotalPopulation[CountryCounter] ← 0
FOR AgeGroupCounter ← 1 to AgeGroupNo
TotalPopulation[CountryCounter] = TotalPopulation[CountryCounter] +
CountryPopulation[CountryCounter, AgeGroupCounter]
NEXT AgeGroupCounter

// calculate and output country's information


OUTPUT "Country ID: " + CountryID[CountryCounter]
OUTPUT "Total population: " + TotalPopulation[CountryCounter]
Rank[CountryCounter] = RANK(TotalPopulation[CountryCounter])
OUTPUT "Rank: " + Rank[CountryCounter]
TotalRank = TotalRank + Rank[CountryCounter]
NEXT CountryCounter

Question 8

The 1D array AnimalID[] contains the identification numbers of animals in a zoo. The
2D array AnimalWeight[] contains the weight for each animal in different months, for
each animal. The position of each animal's data in the two arrays is the same, for
example, the animal in position 11 in AnimalID[] and AnimalWeight[] is the same.

The variable AnimalNo contains the number of animals in the zoo. The variable
MonthNo contains the number of months in a year. All animals have their weight
measured in the same number of months.

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

Animals are monitored for their weight changes over the year. A warning is issued if
an animal's weight changes by more than 10% in any month.

Write a program that meets the following requirements:

● calculates the average weight for each animal in all months


● outputs for each animal:
○ identification number
○ average weight
○ warning issued (yes/no)
● calculates, stores and outputs the total number of warnings issued for all
animals in the zoo.

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 array

// meaningful identifier names and appropriate data structures (variables, constants and the
// given arrays) to store all the data required
DECLARE AverageWeight : ARRAY[1:50] OF INTEGER
DECLARE Warning : ARRAY[1:50] OF STRING
DECLARE MonthCounter : INTEGER
DECLARE AnimalCounter : INTEGER
DECLARE TotalWarnings : INTEGER

CONSTANT WarningThreshold = 10

// initialisation processes for this scenario, initialising the running totals used for
// warnings
TotalWarnings ← 0

FOR AnimalCounter ← 1 to AnimalNo


AverageWeight[AnimalCounter] ← 0
FOR MonthCounter ← 1 to MonthNo
AverageWeight[AnimalCounter] = AverageWeight[AnimalCounter] +
AnimalWeight[AnimalCounter, MonthCounter]
NEXT MonthCounter
AverageWeight[AnimalCounter] = ROUND(AverageWeight[AnimalCounter]/MonthNo)

// calculate and output animal's information


OUTPUT "Animal ID: " + AnimalID[AnimalCounter]
OUTPUT "Average weight: " + AverageWeight[AnimalCounter]
Warning[AnimalCounter] = "no"
FOR MonthCounter ← 1 to MonthNo
IF ABS(AnimalWeight[AnimalCounter, MonthCounter] -
AverageWeight[AnimalCounter])/AverageWeight[AnimalCounter] > WarningThreshold/100
Warning[AnimalCounter] = "yes"
NEXT MonthCounter
OUTPUT "Warning issued: " + Warning[AnimalCounter]
TotalWarnings = TotalWarnings + Warning[AnimalCounter]
NEXT AnimalCounter

// output the total number of warnings issued for all animals


OUTPUT "Total warnings issued: " + TotalWarnings
Question 9

The 1D array PlayerID[] contains the identification numbers of players in a sports


team. The 2D array PlayerScore[] contains the score for each player in different games,
for each player. The position of each player's data in the two arrays is the same, for
example, the player in position 13 in PlayerID[] and PlayerScore[] is the same.

The variable PlayerNo contains the number of players in the sports team. The variable
GameNo contains the number of games played in a season. All players have their
score recorded in the same number of games.

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

Players are awarded points based on their average score in each game.

Average score Points awarded


greater than or equal to 10 3
greater than or equal to 7 and less than 10 2

less than 7 1

Write a program that meets the following requirements:

● calculates the average score for each player in all games


● outputs for each player:
○ identification number
○ average score
○ points awarded
● calculates, stores and outputs the total points awarded to all players in the
sports team.

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 arra


// meaningful identifier names and appropriate data structures (variables, constants and the
// given arrays) to store all the data required
DECLARE AverageScore : ARRAY[1:50] OF INTEGER
DECLARE Points : ARRAY[1:50] OF INTEGER
DECLARE GameCounter : INTEGER
DECLARE PlayerCounter : INTEGER
DECLARE TotalPoints : INTEGER

CONSTANT Points3 = 3
CONSTANT Points2 = 2
CONSTANT Points1 = 1

// initialisation processes for this scenario, initialising the running totals used for
// points
TotalPoints ← 0

FOR PlayerCounter ← 1 to PlayerNo


AverageScore[PlayerCounter] ← 0
FOR GameCounter ← 1 to GameNo
AverageScore[PlayerCounter] = AverageScore[PlayerCounter] +
PlayerScore[PlayerCounter, GameCounter]
NEXT GameCounter
AverageScore[PlayerCounter] = ROUND(AverageScore[PlayerCounter]/GameNo)

// calculate and output player's information


OUTPUT "Player ID: " + PlayerID[PlayerCounter]
OUTPUT "Average score: " + AverageScore[PlayerCounter]
IF AverageScore[PlayerCounter] >= 10
Points[PlayerCounter] = Points3
ELSE IF AverageScore[PlayerCounter] >= 7
Points[PlayerCounter] = Points2
ELSE
Points[PlayerCounter] = Points1
OUTPUT "Points awarded: " + Points[PlayerCounter]
TotalPoints = TotalPoints + Points[PlayerCounter]
NEXT PlayerCounter

// output the total points awarded to all players


OUTPUT "Total points awarded: " + TotalPoints

You might also like