Problem Solving and Pseudocode
We will use these resources to learn how to design algorithms and write pseudocode.
|
Learning Pseudocode:
Part 1 - the Basics
Part 2 - Repetition Structures
Part 3 - Decision Structures
Part 4 - Putting it all Together
Practice Problem Solutions are here
Part 1 - the Basics
Part 2 - Repetition Structures
Part 3 - Decision Structures
Part 4 - Putting it all Together
Practice Problem Solutions are here
What is Pseudocode?
BBC Education Materials
Designing Algorithms
Practice Problems
Create Pseudocodes for each problem.
1. You are watching TV in the living room and you feel hungry. You want to make a ham and cheese sandwich. The materials are all in the kitchen fridge. You will make the sandwich in the kitchen.
2. You're selling candy. There are three choices: a lollipop, a chocolate bar or some gummy treats. When a person comes in to the store, they ask for one of the three candies. If they ask for one of the three, you sell them the candy. If they ask you for something you don't have, have them make another choice.
3. You want to buy a paper at the corner store. You need to walk there, go in, check if there are papers in stock (what do you do if there are no papers?), pay for the paper and return home.
4. It's the first day of Winter Vacation and you are thinking about going to the Big Hill to do some snow-boarding.
a) What things must you check
b) Make a pseudocode for going snowboarding.
5. It's your sibling's birthday. You need to plan and run the party. You start 2 weeks before the birthday. List the steps you need for inviting guests (up to 10), ordering food and a birthday cake. Make sure no more than 10 people confirm they'll attend.
6. You work in a burger restaurant. You wait for a customer to order a burger. Once they've paid, you take their order and make the burger and serve it to them. When the day is over, you go home.
7. Write programs to calculate:
a. the area of a circle of radius 10 m,
b. the annual interest payable on a loan of $5365.25 at
12.5%, and
c. the sales tax payable at 13% on a purchase of $12.50.
8. There are 2.54 cm in one inch. Write a program to input the length of a desk in inches and output its length in centimeters.
Use a constant for the conversion factor. Be sure to prompt for the input and to label the output.
9. Write a program that asks for a person’s year of birth and outputs their age in the current year. Write the program to
work for whatever the current year happens to be.
10.Write a program that inputs the starting time and finishing time of an automobile trip as well as the distance in kilometers
traveled and outputs the average speed in km/hr. The times are to be given in two parts: the hours, then the minutes.
11. Write a program that reads in four numbers and then outputs the four numbers all on one line with commas between the
numbers.
12. Write a program to input a name and output a message that greets a name. For example, if the name is "Sue", then the
message might be "Hello Sue!". Use constants for the greeting.
13. Write a program to calculate and output the product of three numbers entered via the keyboard. Also output the square of the product.
14. The Prom Committee at your school will sell tickets at $65 per person. Expenses include the cost of the food, the DJ, the
hall, the decorations, and the waiting staff. To these expenses, add $100 for miscellaneous expenditures. Write a
program to ask for each of the expense totals incurred and then calculate and output to the committee how many tickets
they must sell to break even.
finished at P100.
1. You are watching TV in the living room and you feel hungry. You want to make a ham and cheese sandwich. The materials are all in the kitchen fridge. You will make the sandwich in the kitchen.
2. You're selling candy. There are three choices: a lollipop, a chocolate bar or some gummy treats. When a person comes in to the store, they ask for one of the three candies. If they ask for one of the three, you sell them the candy. If they ask you for something you don't have, have them make another choice.
3. You want to buy a paper at the corner store. You need to walk there, go in, check if there are papers in stock (what do you do if there are no papers?), pay for the paper and return home.
4. It's the first day of Winter Vacation and you are thinking about going to the Big Hill to do some snow-boarding.
a) What things must you check
b) Make a pseudocode for going snowboarding.
5. It's your sibling's birthday. You need to plan and run the party. You start 2 weeks before the birthday. List the steps you need for inviting guests (up to 10), ordering food and a birthday cake. Make sure no more than 10 people confirm they'll attend.
6. You work in a burger restaurant. You wait for a customer to order a burger. Once they've paid, you take their order and make the burger and serve it to them. When the day is over, you go home.
7. Write programs to calculate:
a. the area of a circle of radius 10 m,
b. the annual interest payable on a loan of $5365.25 at
12.5%, and
c. the sales tax payable at 13% on a purchase of $12.50.
8. There are 2.54 cm in one inch. Write a program to input the length of a desk in inches and output its length in centimeters.
Use a constant for the conversion factor. Be sure to prompt for the input and to label the output.
9. Write a program that asks for a person’s year of birth and outputs their age in the current year. Write the program to
work for whatever the current year happens to be.
10.Write a program that inputs the starting time and finishing time of an automobile trip as well as the distance in kilometers
traveled and outputs the average speed in km/hr. The times are to be given in two parts: the hours, then the minutes.
11. Write a program that reads in four numbers and then outputs the four numbers all on one line with commas between the
numbers.
12. Write a program to input a name and output a message that greets a name. For example, if the name is "Sue", then the
message might be "Hello Sue!". Use constants for the greeting.
13. Write a program to calculate and output the product of three numbers entered via the keyboard. Also output the square of the product.
14. The Prom Committee at your school will sell tickets at $65 per person. Expenses include the cost of the food, the DJ, the
hall, the decorations, and the waiting staff. To these expenses, add $100 for miscellaneous expenditures. Write a
program to ask for each of the expense totals incurred and then calculate and output to the committee how many tickets
they must sell to break even.
finished at P100.