More Selection Control Structures
Objective
- Define the problem by constructing an algorithm using pseudocode
- Create an IPO diagram showing input, output, and processing steps
- What control structures (sequence, selection and repetition) are required?
- What variables are required?
- Show a check of your solution with test data for at least two valid test cases
1. Read and sort letters
Design an algorithm that will prompt the user for five letters, receive those letters as input, sort them into ascending sequence and display them to the monitor
2. Process customer record
A program is required to read a customer’s name, a purchase amount and a tax code.
The tax code has been validated and will be one of the following:
0 tax exempt (0%)
1 state sales tax only (3%)
2 federal and state sales tax (5%)
3 special sales tax (7%)
The program must then compute the sales tax and the total amount due,and print the customer’s name, purchase amount, sales tax and total amount due.
3. Calculate employee's pay
A program is required by a company to read an employee’s number, pay rate and the number of hours worked in a week. The program is then to validate the pay rate field and the hours worked field and, if valid, compute the employee’s weekly pay and then print it and the input data.
Validation: According to the company’s rules, the maximum hours an employee can work per week is 60 hours, and the maximum hourly rate is $25.00 per hour. If the hours worked field or the hourly rate field is out of range, the input data and an appropriate message are to be printed and the employee’s weekly pay is not to be calculated.
Weekly pay calculation: Weekly pay is calculated as hours worked times pay rate. If more than 35 hours are worked, payment for the overtime hours worked is calculated at time-and-a-half.