ICS3U1 - Pseudocode Questions

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

Level 1

1. Create a program that prompts the user for two numbers and then displays the sum,
product, and quotient of the two numbers
● INPUT num1
● INPUT num2
● sum = num1 + num2
● product = num1 * num2
● quotient = num1 / num2
● DISPLAY sum
● DISPLAY product
● DISPLAY quotient
2. Create a program that prompts for length, width, and height then calculates the
volume of a rectangular prism
● INPUT length
● INPUT width
● INPUT height
● volume = length * width * height
● DISPLAY volume
3. Create a program that prompts the user for the number of burgers ($5.99), fries
($3.50), and drinks ($1.99) they would like to purchase. Calculate the final total,
including the 14% tax at the end
● INPUT burgers
● INPUT fries
● INPUT drinks
● total = (burgers * 5.99) + (fries * 3.50) + (drinks * 1.99)
● total = total * 1.14
● DISPLAY total
4. Using the interest rate formula given below, create a program that calculates how
much interest someone would earn on their investment. Prompt the user to enter the
principal amount (how much they invested), the number of years they are investing
for, and the interest rate in decimal form. Display the amount the user would have at
the end of the investment period
● INPUT principal
● INPUT numofyears
● INPUT interestRate
● total = principal * (1 + (interestRate * numofyears))
● DISPLAY tota
Level 2

1. A program that will find the largest of three numbers A, B, and C.


● INPUT numA
● INPUT numB
● INPUT numC
● INITIALIZE largest = -1000000
● IF numA > largest, largest = numA
● IF numB > largest, largest = numB
● IF numC > largest, largest = numC
● DISPLAY largest
2. Write a pseudocode for a program that will calculate the total bill for a restaurant.
Program should display tip, tax and total bills. If the subtotal of the bill is less than $10
there is not tax, tip is 15% of the subtotal.
● INPUT bill
● INITIALIZE tip
● tip = bill * 0.15
● INITIALIZE tax
● If bill >= 10, tax = bill * 0.13
● INITIALIZE total
● total = bill + tip + tax
● DISPLAY tip
● DISPLAY tax
● DISPLAY total
3. Write pseudo code to print all multiples of 5 between 0 and 100 (including endpoints).
● if (i + 1) % 5 = 0, DISPLAY (i + 1)
● LOOP to Line 1 (100 Times)
4. Write a pseudo code for the following problem. Tickets for the Barrie Colts home
games are $12.00 for red seats and $10.00 for blue seats. However, if you are a child
(12 years of age or under), then it is a flat rate of $6.00. Your pseudocode should ask
how many seats of each color and how many children, then display the total value.
● INPUT BlueSeats
● INPUT RedSeats
● INPUT numOfChildren
● total = (BlueSeats * 10) + (RedSeats * 12) + (numOfChildren * 6)
● DISPLAY total
5. Printing prices are typically based on the number of copies printed. For example:
0-99 $0.30per copy
100-499 $0.28per copy
500-999 $0.26 per copy
Over 1000 $0.25 per copy
Create a pseudocode for an application that prompts the user for the number of copies
to print then displays price per copy then the total price for the job. (Remember there
is a 13% hst)
● INPUT numOfCopies
● INITIALIZE price
● If numOfCopies > 0 and < 100, price = numOfCopies * 0.3
● If numOfCopies > 99 and < 500, price = numOfCopies * 0.28
● If numOfCopies > 499 and < 1000, price = numOfCopies * 0.26
● If numOfCopies > 1000, price = numOfCopies * 0.25
● price = price * 0.13
● DISPLAY price

Level 3

1. Write a pseudocode for a program that will display a countdown from 1,000,000 to 1.
● INITIALIZE count = 1,000,000
● DISPLAY count
● count = count - 1
● LOOP back to Line 1 until count = 0
2. Write a pseudocode for a program that will display all even numbers between 50 and
100 inclusive.
● INITIALIZE count = 50
● if count % 2 = 0, DISPLAY count
● count = count + 1
● LOOP back to Line 2 until count = 101
3. Create a program that will prompt the user for two numbers. The program will then
display all the numbers in between including endpoints.
● INPUT num1
● INPUT num2
● INITIALIZE count = 0
● IF num1 + count <= num2, print num1 + count
● ELSE, break out of loop
● count = count + 1
● LOOP to line 4

4. Create a program that prints the first 20 numbers that is divisible by 5. (


5..10..15..20.....)
● INITIALIZE count = 0
● INITIALIZE num1 = 0
● If count < 20
○ num1 += 1
○ If num1 % 5 = 0, DISPLAY num1 and count +=1
● Else, break out of loop
● LOOP to line 3
5. Create a program that will print the first 100 odd numbers
● INITIALIZE count = 0
● INITIALIZE num1 = 0
● If count < 100
○ num1 += 1
○ If num1 % 2 = 1, DISPLAY num1 and count +=1
● Else, break out of loop
● LOOP to line 3
6. Create a program that will print the first 20 numbers divisible by 2 and 3.
● INITIALIZE count = 0
● INITIALIZE num1 = 0
● If count < 20
○ num1 += 1
○ If num1 % 6 = 0, DISPLAY num1 and count +=1
● Else, break out of loop
● LOOP to line 3
Level 4

1. Create a program that will prompt the teacher the number of students in the class. The
program will then prompt for marks for each student. The program will display the highest
mark, lowest mark, class average, number of students that failed, number of students that got
over an 80.
● INPUT students
● INITIALIZE marks = []
● INPUT mark, append into marks
● LOOP back to Line 3 until the iteration of the loop has reached int value of students
● INITIALIZE highest = -10000
● IF mark > highest, highest = mark
● LOOP back to line 6, loop through all values in the list “marks”
● INITIALIZE lowest = 10000
● IF mark < lowest, lowest = mark
● LOOP to line 9, loop through all values in the list “marks”
● INITIALIZE average = 0
● average += mark
● LOOP back to line 12, which loops through all values in the list “marks”
● average = average/students
● INITIALIZE failed = 0
● IF mark < 50, failed += 1
● LOOP back to line 16, which loops through all values in the list “marks”
● INITIALIZE eighty = 0
● IF mark > 80, eighty += 1
● LOOP back to line 19, which loops through all values in the list “marks”
● DISPLAY highest, lowest, average, failed, eighty

2. Create a program that prompts a MLB baseball player the number of hits that he got in
each game he played in the season (162 games). The program should display his average score
and the game where he had his highest score and lowest hits.
● INITIALIZE most = {}
● INITIALIZE least = {}
● INITIALIZE average []
● INITIALIZE highest = -10000
● INITIALIZE lowest = 10000
● INPUT numhits
● APPEND numhits into average
● IF numhits > highest, numhits = highest, most = {(iteration of loop + 1): numhits}
● IF numhits < lowest, numhits = lowest, least = {(iteration of loop + 1): numhits}
● LOOP back to line 2 (162 times)
● average = average/162
● DISPLAY average, most(first value will be the game, second will be the score), least

3. Create a program that will prompt the user for different temperatures. The program should
ask if the user wants to continue entering or not. The program should display the number of
temperatures entered, average temp, coolest temp, warmest temp.
● INITIALIZE numOfTemps = 0
● INITIALIZE temps = []
● INITIALIZE warmest = -10000, coolest = 10000, average = 0
● INPUT boolean = yes/no
● IF boolean = yes, INPUT temperature
○ numOfTemps += 1
○ average += temperature
○ IF temperature > warmest, warmest = temperature
○ IF temperature < coolest, coolest = temperature
● ELSE, break out of loop
● LOOP back to line 4
● average = average/numOfTemps
● DISPLAY numOfTemps, average, warmest, coolest

4. Create a program that will prompt the user for numbers. The program will stop prompting
once a negative number has been entered. The program will display the total entries, lowest
entry, highest entry, average, number of entries that are even and odd. (excluding the
negative number)
● INITIALIZE totalEntries = 0
● INITIALIZE lowest = 1000000, highest = -1000000, average = 0, even = 0, odd = 0
● INPUT number
● IF number >= 0,
○ totalEntries += 1
○ average += temperature
○ IF number > highest, highest = number
○ IF number < coolest, lowest = number
○ IF number % 2 = 0, even += 1
○ ELSE, odd += 1
● ELSE, break out of loop
● LOOP back to line 4
● average = average/totalEntries
● DISPLAY totalEntries, lowest, highest, average, even, odd

Level 5 (…. If you dare)

1. Create a program that will prompt the user for a positive number. The program will display
if the number is PRIME or not.
● count = 2
● INPUT number
● IF number = 2, DISPLAY “PRIME”
● IF count < number,
○ IF number / count = type(int), DISPLAY “NOT PRIME”
■ Break out of whole loop
○ count += 1
○ IF count = number, DISPLAY “PRIME”

You might also like