Professional Documents
Culture Documents
CS Test 4 - Problem - Solving and Design
CS Test 4 - Problem - Solving and Design
CS Test 4 - Problem - Solving and Design
2. Write a program that finds the biggest of three integers, using nested if statements.
4. Write a program (using Case) that applies bonus points to given scores in the range [1…9]
by the following rules:
If the score is between 1 and 3, the program multiplies it by 10.
If the score is between 4 and 6, the program multiplies it by 100.
If the score is between 7 and 9, the program multiplies it by 1000.
If the score is 0 or more than 9, the program prints an error message.
5. Your school needs to choose SRC leaders for next year. The IG and AS learners have cast
their votes. Write a program to determine the chances of a specific learner to become a SRC
leader. The following values have to be entered:
The total number of votes is used to express the learner’s chances of becoming an SRC
leader as definitely, probable, possible or unlikely.
Classification Criteria
Definitely 60% or more votes
Probable Less than 60% but more than 47% of votes
Possible From 40% - 47% of the votes
Unlikely Less than 40% of the votes
Display the total number of votes casted, the percentage of the total votes obtained and the
chances of the learner to become a SRC leader based on the given criteria.
6. Write a program which can be used to convert letters of the alphabet (upper and lower case)
to its corresponding ASCII value and vice versa. If a user enters an illegal number or letter,
an error message should displayed.
The program must display a message to tell the user whether the number guessed is lower
or higher than the secret number.
8. The organisers of a singing completion use a grading system to see whether a contestant
gets through to the final round:
A score out of 100 must be calculated for each contestant using the percentage of public
votes, the number of judges’ votes and bonus points. The score of a contestant is
calculated as follows:
o The percentage of votes received from the public is converted to a value out of 60.
o The total number of votes from the judges (there are 4 judges) is converted to a value
out of 30.
o They score 10 additional bonus points if they receive more than 75% of the public
votes or more than 75% of the judges’ votes.
To qualify to be in the final round, a contestant must have a score of at least 75 and have
the vote of at least two of the judges.
The total number of members of the public who voted, the number of member of the public
who voted for this contestant and the number of judges who voted for this contestant.
Determine and display a message indicating whether the contestant qualifies for the final
round or not.
If the name starts with a vowel, a password needs to be compiled by combining the following:
If either the name or the surname contains less than 3 characters, an error should be
displayed.
For example:
Haydne Mole will return result Hay738Mol
Uriel Grobbelaar will return the result iel464aar
Li Xavi will return the result “Both Name and Surname should be at least 3 characters
long”
10. A company produces cooldrinks. They have three different machines that each delivers
volumes of cooldrinks per hour:
Machine A: 100 litres per hour
Machine B: 150 litres per hour
Machine C: 180 litres per hour
Enter the letter indicating the machine and a number indicating the number of hours the
machine will be used that day. More than one machine can be used per day. The program
must be able to work with a capital or a lowercase letter as input.
If the user enters an invalid letter (such as D), an error message must be displayed, and
the user must get the opportunity to re-enter the letter.
Display the number of litres the machine will produce each time the details of that machine
is entered.
Add up the litres for each machine, and display the following:
o The total volume of cooldrink the company will produce using all the machines for the
times that were entered that day.
o The cost to produce the total volume of cooldrink if the company produces cooldrink
at a cost of R2.00 per litre.
o The profit the company make if they sell the cooldrink at R4.50 per litre.
o If new machines are bought they can produce the cooldrink at R1.80 per litre.
Calculate and display the profit the company would have made with the figures entered
for that day if they have been using the new machines.