Tutorial Sheet 3
Tutorial Sheet 3
Write pseudocode for each example (a through e) making sure your pseudocode
is structured but accomplishes the same tasks as the flowchart segment.
a.
b.
c.
d.
e.
4. Design the logic for a program that outputs every number from 1 through
20 along with its value doubled and tripled.
5. Design the logic for a program that outputs every even number from 2
through 100. 5. Design the logic for a program that outputs numbers in
reverse order from 25 down to 0.
6. Design the logic for a program that allows a user to enter a number.
Display the sum of every number from 1 through the entered number.
7. Prompt for and input a saleswoman’s sales for the month (in dollars) and
her commission rate (as a percentage). Output her commission for that
month. Note that you will need to convert the percentage to a decimal.
You will need the following variables:
SalesAmount CommissionRate CommissionedEarne You will need the
following formula: CommissionedEarned = SalesAmount *
(CommissionRate/100)
9. The owners of the Super Supermarket would like to have a program that
computes the monthly gross pay of their employees as well as the
employee’s net pay. The input for this program is an employee ID number,
hourly rate of pay, and the number of regular and overtime hours worked.
Gross pay is the sum of the wages earned from regular hours and overtime
hours; overtime is paid at 1.5 times the regular rate. Net pay is gross pay
minus deductions. Assume that deductions are taken for tax withholding
(30 percent of gross pay) and parking ($10 per month). You will need the
following variables:
10 Shannon and Jasmine bowl as a tem. Each of them bowls three grames
in a tournament. They would like to know their individual averages for
their three games and the team average. Allow the user to input the
scores for each player. Output Shannon’s average, Jasmine’s average,
and the team’s average. You will need the following variables:
10. Kim wants to buy a car. Help Kim compute the monthly payment on a
loan, given the loan amount, the annual percentage rate of interest, and
the number of montly payments. The program should allow Kim to input
the loan amount, the interest rate, and how many payments she wants to
make. It should then compute and display the monthly payment.
11. Input a number entered by the user and display “Positive” if it is greater
than zero, “Negative” if it is less than zero, and “Zero” if it is equal to zero.
12. Develop a menu-driven program that inputs two numbers and, at the
user’s option, finds their sum, difference, product, or quotient.
13. Input a number (X) and create a program that allows the user to select
finding the area (Area) of one of the following:
15. Compute the income tax due on taxable income entered by the user,
given the data as shown in the following table. Be sure to include error
checking to make sure the user does not enter a negative number. Assume
all entries are integer values.
From To
$0 $49,999 $0 + 5% of amount over $0
$50,000 $99,999 $2,500 + 7% of amount over
$50,000
$100,000 …. $6,000 + 9% of amount over
$100,000
16. Write a program that allows the user to input a total dollar amount for
an online shopping order and computes and outputs the shipping cost
based on the following schedule:
17. Write a program that allows the user to enter his or her name. The
program should out put a username for entry into a website. The user
should be prompted to enter a first name, middle initial, and last name. If
the user does not have a middle initial, the entry should be “none”. In this
case, the output will be a username that concatenates the first and last
names with a dot between them. If the user has a middle initial, the output
username should be in form first.middle_initial.last. For example, a user
whose name is Harold Nguyen
would have Harold.Nguyen for his username and a user whose name is
Maria Anna Lopez would have Maria.A.Lopez for a username.
18. Find the sum of the squares of the integers from 1 to MySquare, where
MySquare is input by the user. Be sure to check that the user enters a
positive integer.
19. Input a list of people’s ages from the user (terminated by 0) and find
the average age. Be sure to check that the user enters only positive
numbers.
N! = 1 X 2 X 3 X …. X N
For example:
5! = 1 X 2 X 3 X 4 X 5 = 120
7! = 1 X 2 X 3 X 4 X 5 X 6 X 7 = 5,040
Find N!, where N is a positive integer input by the user. (Hint: Initialize
a Product to 1 and user a loop to multiply that product by successive
integers.) Be sure to check that the user enters a positive integer.