Question

Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...

Use program control statements in the following exercises:

Question 1

. Write pseudocode for the following: • Input a time in seconds. • Convert this time to hours, minutes, and seconds and print the result as shown in the following example: 2 300 seconds converts to 0 hours, 38 minutes, 20 seconds.

Question 2.

The voting for a company chairperson is recorded by entering the numbers 1 to 5 at the keyboard, depending on which of the five candidates secured a vote. Enter 0 to indicate that all votes have been input. Write the pseudocode for the program that will count the number of votes for each of the five candidates. Once all the votes have been entered, print the total for each candidate and the total of all the valid votes. Make provision for an error message to be displayed to the user when an invalid number (a number not in the range 0 to 5) is entered.

Question 3.

Write the pseudocode for a program that will: • calculate pay for each employee in a company. • print these details in a monthly report. The input values are: employee number, name, hours worked, and the rate of pay. The output for each employee includes the employee number, name, hours worked, rate of pay, and the gross pay. The hours worked and the gross pay for each employee must be accumulated and these totals must be printed after an employee number of zero has been entered. The hours worked must be entered as a whole number (without minutes). Processing stops when an employee number of zero is entered. Construct the program in such a way that when the user enters 0 to stop the program, the user will not be prompted to enter the rest of an employee’s details.

Question 4.

The task is to produce a student grading report. The following input values are entered: student number, student name, maximum test score, and student test score. The percentage obtained by each student must be calculated. This percentage will be matched against the corresponding class message: • 0 – 44 Fail • 45 – 49 Supplementary • 50 – 59 3rd class • 60 – 69 2nd class • 70 – 74 Upper second • 75 – 100 First Totals for each grading class must be accumulated and printed after a student number of zero is entered.

Question 5.

Write the pseudocode for a program that will print electricity bills for a designated area. The following data is input: customer’s name, address, this month's reading, and last month’s reading. The output is the customer’s name, address, this month’s reading, last month’s reading, and the amount billed. The unit price (in cents) is entered once, at the start of the process, before any customer data is entered. Each customer’s information will be read and processed to generate an electricity bill. The amount billed (in rand) and the number of units used must be accumulated for all customers, and printed after the last record has been processed. Use the following specifications for the program: • The first input-field must be the customer name. • Processing terminates when the name “ZZZ” is entered. • The program should accept input for the address, last month’s reading, and this month’s reading only if a valid value is entered in the name field. Arrange the output to look as follows: ******ELECTRICITY BILL****** Name: Mr S. Mqamelo Address: 25 Street, This month’s reading: 10567 Last month’s reading: 9876 Amount due: R 276.40 ******SUMMARY REPORT****** Total amount billed: R394 849.20 Total units used: 98 7123

Question 6.

A secretary working in the subscriptions department for a magazine inputs data at the keyboard. For each subscriber a CODE field, which holds a value 38 | P a g e of 1 to 5 depending on the type of subscriber, is input. The subscriber types are as follows: • Code 1 = Individual subscriber • Code 2 = Associate subscriber (single copy) • Code 3 = Associate subscriber (multiple copies) • Code 4 = Corporate subscriber (single copy) • Code 5 = Corporate subscriber (multiple copies) Count the number of subscribers in each category. Processing stops when a code of zero is entered. The individual totals as well as the total number of subscribers must then be printed. Ensure that the program displays an error message if the code entered is not 0, 1, 2, 3, 4, or 5.

Question 7.

Input the following: • Salesperson number • Gender (F or M) • Department number (1 or 2) • Sales amount • Basic salary Write the pseudocode to calculate how much a salesperson earns when his/her commission and basic salary are combined. If a salesperson sells above R3 000 he/she earns 10% commission, otherwise he/she earns no commission. For each salesperson print his or her number, gender, department number, sales amount, basic salary, and total salary. At the end of the report, print how many women work in each department. Processing continues until a salesperson number of zero is entered. The program must adhere to the following specifications: • The first input must be the salesperson number. If a number of 0 is entered, a summary report (showing the total number of women in each department) must be printed. • If a salesperson number of 0 is entered, the user must not be prompted for other information. • The gender of the salesperson can be one of the following: M, or F. If any other character is entered the user must be prompted for the correct gender. The program will not continue until the correct gender is entered. • The same applies to the department number.

Question 8.

Input the following: • Employee number • Gender (M or F) • Salary Write the pseudocode to count how many men earn above R1 000 and how many women earn below R500. Processing should continue until an employee number of zero is entered. The program should output the following: • Number of men earning above R1 000 • Number of women earning below R500

Question 9.

Input: • Department number (1 or 2) • Salesman name • Sales amount If a salesperson sells products worth more than R1 000 he/she gets 5% commission; otherwise he/she gets 3% commission. Print a report showing the department number, salesperson name, sales amount, and commission for each salesperson. At the end of the report, print the total number of salespeople for each department and the total sales amount for all salespeople. Processing continues until a department number of zero is entered.

Question 10.

A car hire company produces a monthly analysis report. Input: • Car type (1 – 3). • Odometer reading before the car was taken. • Odometer reading after the car was returned. • Number of days the car was used. Output: • Car type. • Number of kilometres travelled. • Number of days used. • Cost of hiring the car. The following conditions apply: • The cost of hiring (per km) differs from one car type to the next. Type 1: Executive R20 Type 2: Luxury R15 40 Family car R10 o Further conditions apply to car types 1 and 3: Type 1: Clients may use this car for a maximum of five days. If the client exceeds this limit, a 10% surcharge is added to the final cost. Type 3: Because of the popularity of this class, clients may use this car for a maximum period of 10 days. If the 10-day limit is exceeded, the client is charged an extra R3 per kilometre. At the end of the report, print out the total number of kilometres travelled, the number of cars that were hired, and the total number of days that the car was used FOR EACH CAR TYPE (Hint: there will be nine totals). Processing continues until a car type of zero is entered.

Question 11.

Input an amount in rand and cents (in decimals of a rand e.g. R12.30 would be 12.3). Determine and print out the maximum number of R10 notes, 50-cent coins, 5cent coins, and 1-cent coins of which the amount input could consist. The program must first calculate the number of R10 notes and then with the remainder, calculate the number of 50-cent coins, and so on.

Question 12.

Write the pseudocode for the following: A company needs to print pay-slips for its employees. Each record contains the following: a. number, b. name, c. hours, d. gender, and e. code. Each employee’s gross pay must be calculated and deductions made on the following basis: CODE 1: Full-time employee: Rate R30 per hour Deductions: Men PAYE 15% of gross pay, Medical aid R200 Women PAYE 10% of gross pay Medical aid R100 CODE 2: Part-time employee: Rate R20 per hour Deductions: Men PAYE 10% of gross pay Women PAYE 5% of gross pay No medical aid for this category. Print out a pay-slip for each employee, showing all the employee details, gross pay, all the deductions, and the net pay. Processing continues until a number of zero is entered. Then print out: • The total number of men who work full time. • The total PAYE paid by women. • The total amount paid out by the company to all its employees.

Question 13.

An investor deposits a fixed amount of money into a savings account every month. To open the account a sum of money has to be deposited as a starting balance. The bank compounds interest monthly. Input details are: name, account number, gender, age, initial deposit, and monthly deposit amount. The interest earned must be accumulated and the program should stop listing information about the account status when the total interest earned is greater than the original deposit amount. • If the investor is a man or under 30, the interest rate is 5% per year. • If the investor is a woman and over 60, the interest rate is 10% per year. • For anyone else, the interest rate is 7% per year. Each month the investor receives a printout reflecting the account status, i.e. total balance and interest for that month earned on the total balance. At the end of each year the investor receives a printout of accumulated totals. A final summary of the account balance, as well as the total interest earned over the period, must be shown when the program stops.

Question 14.

Write the pseudocode for the following program: • A company sales manager requires a sales analysis of the two products on offer at the end of the month. • The company employs five salespeople. • Input values for each salesperson are name, number, gender, and total units sold for the month, for each product (one and two). • The salary of each salesperson is strictly commission-based. Each salesperson earns a basic commission calculated as 12.5% of his/her total sales. • If a salesperson sells more than R1 000 of product two, he or she receives an additional 10% commission on product two. If not, commission for sales of product two is reduced to 5% (i.e. instead of receiving the basic 12.5% commission for sales of product two, a penalty is paid). • If a saleswoman sells more than R500 of product one, she receives a bonus of R100. • An added bonus of R750 is given to each salesperson whose total commission is more than R6 000. • Each employee receives a printed pay-slip showing all the employee details, gross pay, all the deductions and/or additions, and the net pay. • The unit prices for the two products are as follows: o Product 1: R250 o Product 2: R175 42 At the end of processing, the manager wants to know: • The total number of items sold. • The total number of women and the total number of men that received a bonus. • The number of women employed by the company. • Total salary paid out (i.e. total nett pay).

Question 15.

Ten numbers are input by the user. There are three choices for each number: a) Multiply the number by 2. b) Add 6 to the number. c) Divide the number by 2, and then test to see if the answer is whole. If the answer is whole, an appropriate message must be printed. The number, choice, and answer must be printed. Should option ‘c’ be chosen, the appropriate message must also be printed.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1.

Pseudocode to convert the time in seconds to hours, minutes and seconds
Declaration
   number seconds;
   number hours;
   number minutes;
  
Start
  
   input time in seconds;
  
   hours = (Integer)(seconds/3600); // Integer value of result obtained when input seconds/3600
   seconds = seconds - seconds-(hours*3600); // get the remaining seconds
   minutes = (Integer)(seconds/60) // Integer value of result obtained when input seconds/60
  
   print(hours," hours, ",minutes," minutes, ",seconds," seconds")
End  

2.

// Pseudocode to input the voter number and record the number of votes for each candidate
Declaration
   number votes[5] ; //array containing total votes of the 5 candidates
   number voter_num;
   number i;
   number total_votes;
Start
  
   // initialize the number of votes for all candidates as 0
   for(i=0;i<5;i++)
   do
       votes[i] = 0;
   done  
      
   input voter_num;
   // loop to input voter number until 0 is input by the user
   while voter_num != 0
   do  
       // check if invalid voter number
       if(voter_num < 1 or voter_num > 5) then
           print("Invalid voter number. Voter number must be between 1 to 5 (inclusive)")
       else // add the vote to the correct voter         
           votes[voter_num-1] = votes[voter_num-1] + 1;
       end if;
       input voter_num;
   done
  
   total_votes = 0;
   // loop to display the number of votes for each candidate and calculate total valid votes
   for(i=0;i<5;i++)
   do
       print("Candidate ",(i+1), " : ",votes[i]," votes");
       total_votes = total_votes + votes[i];
   done
   // print total valid votes
   print("Total valid votes : ",total_votes);
End  
      

Add a comment
Know the answer?
Add Answer to:
Use program control statements in the following exercises: Question 1 . Write pseudocode for the following:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the pseudocode for the following: A company needs to print pay-slips for its employees. Each record contains the following: a. number, b. name, c. hours, d. gender, and e. code. Each employee’s...

    Write the pseudocode for the following: A company needs to print pay-slips for its employees. Each record contains the following: a. number, b. name, c. hours, d. gender, and e. code. Each employee’s gross pay must be calculated and deductions made on the following basis: CODE 1: Full-time employee: Rate R30 per hour Deductions: Men PAYE 15% of gross pay, Medical aid R200 Women PAYE 10% of gross pay Medical aid R100 CODE 2: Part-time employee: Rate R20 per hour...

  • Program Description: Write the pseudocode for a program that will calculate and display an employee’s gross...

    Program Description: Write the pseudocode for a program that will calculate and display an employee’s gross pay. Input the number of hours an employee worked for each of the 5 days of the week. Add them all up to get his hours worked for the week. Weekly Pay is calculated by adding an employee’s normal pay plus any overtime pay. Normal hours are paid at $10/hr. Any over time is paid at $15/hr. Any hours over 40 are considered overtime....

  • Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that...

    Overview Module 3 Assignment 1 features the design of a pseudocode and a Python program that uses iteration to guess a number from 1 to 10. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. Instructions Write pseudocode for a Python program that uses iteration to guess a number from...

  • JAVA. Write a Java program that accepts the total amount of cars sold and total sales...

    JAVA. Write a Java program that accepts the total amount of cars sold and total sales amount of a car salesperson for a given month. The salesperson’s paycheck is computed as follows: a. Every sales person gets 10% (commission) of total sales b. Sales totals greater than $50,000 get 5% of total sales amount c. 8 or more cars sold earns the salesperson an extra 3% Please remove 30% (taxes) of the gross pay and list the paycheck amount. Your...

  • C++ (i) Write a program that displays the following pattern: * *** ***** ******* ***** ***...

    C++ (i) Write a program that displays the following pattern: * *** ***** ******* ***** ***    * (ii) Katy bought 750 shares of stock at a price of $35.00 per share. She must pay her stockbroker a 2 percent commission for the transaction. Write a program that calculates and displays the following: The amount paid for the stock alone (without the commission) The amount of the commission) The total amount paid (stock plus commission) (iii) Write a program that...

  • 1. Write and debug a MIPS program that performs the following operations . Prompt for and...

    1. Write and debug a MIPS program that performs the following operations . Prompt for and input three integers "a", "b and "c" using syscalls (3 points) Print all numbers starting from "a" upto "b" (including, but not exceeding "b") at an increment equal to value of"c"(5 points) If ba, then no numbers are printed, and a message is printed to inform it to the user. (3 points) Print the number and average of the generated numbers printed. (3 points)...

  • (TCOs C-F) List the names of subroutines of the hierarchy chart, and then write complete pseudocode...

    (TCOs C-F) List the names of subroutines of the hierarchy chart, and then write complete pseudocode for the following problem. You will not have to create a data dictionary for this exercise. Problem: Students get a discount on the tuition paid. The discount is based on a student's code and the registered number of course credits. A student with a code "M" for a military job, and registered for more than four credits is eligible for 5% discount on the...

  • Turning this Pseudocode into the described C++ Program? (will include Pseudocode AND Description of the Program...

    Turning this Pseudocode into the described C++ Program? (will include Pseudocode AND Description of the Program below!) Pseudoode: start   Declarations num deptNum num salary num hrsWorked num SIZE = 7 num totalGross[SIZE] = 0 string DEPTS[SIZE] = “Personnel”, “Marketing”,   “Manufacturing”, “Computer Services”, “Sales”, “Accounting”, “Shipping”                                                      getReady()    while not eof detailLoop()    endwhile    finishUp() stop getReady()    output “Enter the department number, hourly salary, and number of hours worked”    input deptNum, salary, hrsWorked return detailLoop()    if deptNum >= 1 AND deptNum...

  • Write pseudocode for a program where the seating map for a particular performance at a theater...

    Write pseudocode for a program where the seating map for a particular performance at a theater contains 70 rows of 100 seats each. Using an array where applicable, develop the pseudeocode for a program that allows a user to continuously enter each household size and then a) Allows a user to continuously enter a row number and seat number until they enter an appropriate sentinel value for the row number in order to stop entering input. Each time the user...

  • You are to write a program that will process employees and their pay. For each employee...

    You are to write a program that will process employees and their pay. For each employee the program will read in an employee’s name and hourly pay rate. It should also read in the number of hours worked each day for 5 days and calculate his or her total number of hours worked. You must read the hours using a loop. The program should output the employee’s name, gross pay, total withholding amount and net pay. Withholding is made up...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT