Question

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 <= SIZE then

    totalGross[deptNum-1] = totalGross[deptNum-1] + (hrsWorked * salary)

   else

    output “Invalid department number”

  endif

  output “Enter the department number, hourly salary, and number of hours worked”

  input deptNum, salary, hrsWorked

return

finishUp()

  deptNum = 0

  while deptNum < SIZE

       output deptNum+1, DEPTS[deptNum], totalGross[deptNum]

       deptNum = deptNum + 1

  endwhile

return

DESCRIPTION OF PROGRAM:

Design the application logic for a company that wants a report containing a breakdown of payroll by department. Input includes each employee’s department number, hourly salary, and number of hours worked. The output is a list of the seven departments in the company and the total gross payroll (rate times hours) for each department. The department names are shown in Table 6-3. Include appropriate comments (a brief description of the program and descriptions of segments of code), and you must input any number of employees and they may be input randomly from different departments.

Table 6-3:

·  Department Number

Department Name

1

Personnel

2

Marketing

3

Manufacturing

4

Computer Services

5

Sales

6

Accounting

7

Shipping

Please make C++ code to where i can copy it, thank you so much.

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

//Source Code :

#include <bits/stdc++.h>
using namespace std;

class Employee
{
private:
   int deptNum;
   int salary;
   int hrsWorked;
   static const int SIZE = 7;
   int totalGross[SIZE];
   string DEPTS[SIZE];

public:
   //Constructor
   Employee(){
       // Initialize the totalGross as 0
       for (int i = 0; i < SIZE; ++i) {
           totalGross[i] = 0;  
       }

       //Initializing th DEPT names
       DEPTS[0] = "Personnel";
       DEPTS[1] = "Marketing";
       DEPTS[2] = "Manufacturing";
       DEPTS[3] = "Computer Services";
       DEPTS[4] = "Sales";
       DEPTS[5] = "Accounting";
       DEPTS[6] = "Shipping";
   }

   // check whether the input choice is valid or not
   // in case its invalid it prompts the user to enter again
   void checkChoice(char &ch){
       while(ch != 'y' and ch != 'Y' and ch != 'n' and ch != 'N'){
           cout<<"Invalid input... Please enter(y/n) : ";
           cin>>ch;
       }
   }

   //Asks the user if it wants to enter more employee data
   void getReady(){
       cout<<"Do you want to add employee data?(y/n): ";
       char ch;
       cin>>ch;
       checkChoice(ch);

       while(ch == 'y'){
           getInput();
           detailLoop();
           cout<<"Do you want to enter more employee data?(y/n): ";
           cin>>ch;
           checkChoice(ch);
       }
       finishUp();
   }

   //Ask the user to enter deptNum, hrSalary, hrsWorked
   void getInput(){
       cout<<"Enter the department number, hourly salary, and number of hours worked : ";
       cin>>deptNum>>salary>>hrsWorked;      
   }
  
   //check whether the department num is valid or not
   //if valid then add the data in totalGross corresponding to the deptNo
   //else prompt the user to enter again
   void detailLoop(){
       if (deptNum >= 1 and deptNum <= SIZE) {
       totalGross[deptNum-1] = totalGross[deptNum-1] + (hrsWorked * salary);          
       }else{
           cout<<"Invalid department number\n" ;
           getInput();
       }
   }

   //displays the totalGross payroll of each department
   void finishUp(){
       deptNum = 0;
       while (deptNum < SIZE){
           cout<< deptNum+1<<" "<<DEPTS[deptNum]<<" - "<< totalGross[deptNum]<<endl;
          deptNum++;
       }
       return;
   }

};

int main()
{
   Employee e;
   e.getReady();

   return 0;
}

// Scource Code Screenshots :

#include <bits/stdc++.h> using namespace std; class Employee private: int deptNum; int salary; int hrsWorked; static const in// check whether the input choice is valid or not // in case its invalid it prompts the user to enter again void checkChoice(//check whether the department num is valid or not //if valid then add the data in totalGross corresponding to the deptNo //e

//Output Screenshot :

X 06. Command Prompt - O Do you want to add employee data? (y/n): y Enter the department number, hourly salary, and number of

// If you have any query do ask in the comments section.

// If you found the answer helpful do give a Thumbs UP. Happy Learning!!

Add a comment
Know the answer?
Add Answer to:
Turning this Pseudocode into the described C++ Program? (will include Pseudocode AND Description of the Program...
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
  • Find Bugs in the pseudocode // A high school is holding a recycling competition // This program allows a user to enter a student's // year in school (1 through 4) // and number of cans collected // Data is entered continuously until the user wnats

    Find Bugs in the pseudocode// A high school is holding a recycling competition// This program allows a user to enter a student's // year in school (1 through 4)// and number of cans collected// Data is entered continuously until the user wnats to quit// After headings, output is four lines// one for each school year classstart   Declarations      num year      num cans      num SIZE = 4      num QUIT = 9    ...

  • 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....

  • Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses...

    Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program The program will reuse the DATE struct from the previous assignment.  You should also copy in the functions relating to a DATE. The program will create a PAYRECORD struct with the following fields: typedef struct...

  • Styles Program Description Write a C++ program that computes and displays employees' earnings. Prompt the user...

    Styles Program Description Write a C++ program that computes and displays employees' earnings. Prompt the user for type of employee (hourly ("h"or "H") or management ("'m" or "M") If the employee is management: . get the annual salary get the pay period (weekly ("w" or "W"), bi-weekly ("b" or "B") or monthly ("m" or e compute the gross salary for the pay period (Divide annual salary by 52 for weekly, 26 for bi-weekly, and 12 for monthly) deduct from gross...

  • 1. Write a C++ program that will ask the user for their full name and calculate...

    1. Write a C++ program that will ask the user for their full name and calculate the user's weekly salary based on their hourly wage and the number of hours they worked, assuming no overtime at this point. Sample program run: Please enter first name: Elmer Please enter middle initial (Enter space if none): J Please enter last name: Fudd Enter hours worked: 37.5 Enter hourly rate: 10.35 Your name is: Elmer J. Fudd Your weekly salary is: $388.12 2....

  • I need to see the program in C++: You are to write a payroll application for...

    I need to see the program in C++: You are to write a payroll application for a company. You should prompt the user to input two values in the following order. 1. The number of hours they worked. Our company only pays employees for full hours of work and do not count partial hours. Employees are not allowed to round up the time worked. So, 5 would be a valid input, but 5.7 would not be. 2. The hourly rate...

  • 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...

  • // This application reads sales data for a real estate broker. // The user enters a...

    // This application reads sales data for a real estate broker. // The user enters a record for each of 10 salespeople //    containing the salesperson's name, //    the number of properties sold by that person during the month, //    and the total value of those properties. // The data records are sorted by value so the data for //    the top three salespeople can be displayed. // Modify the program to // (1) enter data for any number of...

  • the author's pseudocode    it follows this template 3 Design the logic for a program for Nos...

    the author's pseudocode    it follows this template 3 Design the logic for a program for Nos Encanta Tu Interés credit card company that a) Allows the user to enter their name, credit card number, beginning balane and monthly interest rate b) For the next full year (12 months), 1. Outputs the month number and the balance at the beginning of the month 2. Allows the user to enter the amount of their payment, and the amount of their purchases for...

  • Program description: Write the necessary C++ statements (Program) to calculate the employee's weekly pay. Where :...

    Program description: Write the necessary C++ statements (Program) to calculate the employee's weekly pay. Where : Hour = employee's work hours Rate = employee's hourly pay Wages = employee's weekly pay Given that ( Hour= 31.5 and , Rate = $11.45) Write the variable declarations and initialization sections necessary to compute and print the required calculations. The program should ask the user to input the hours and Rate of pay, then calculate the weekly Wages. Hint: Modify program in project...

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