Bigger Picture/Prologue: What do a paycheck processing company, a pizza store, and an ice cream…

Bigger Picture/Prologue:

What do a paycheck processing company, a pizza store, and an ice cream parlor have in common? On the surface, it may seem like “they have nothing in common”! Yet the magic of algorithms tells us that they may be using similar algorithms to process paychecks, determine cost of pizza, or ice cream. Here is how it works. Whether it’s an employee’s salary, cost of pizza, or ice cream, the cost components may be distributed in the parts below:

1. First cost component is basic cost of pizza or ice cream based on size. In case of employee the base salary will depend on the employee’s title.

2.In case of pizza there may be a percentage of base cost added due to the type and quality of flour used for the pizza pie. (For example organic wheat or multigrain flour will cost more). In case of ice cream a percentage of base cost may be added if milk for ice cream is special type (for example organic milk, or goat milk, or milk of cows that were only fed grass). In case of an employee a percentage of base pay may be added to salary depending upon employee classification and years of service they had with company.

3.Then in case of pizza, additional cost will be added due to number and types of toppings added. In case of ice cream, additional cost will come from adding extras, such as gummy bears, chocolates, and fruits. In case of employee, additional salary components would be employee education level such as associates, or baccalaureate, or master’s degree.

Can you now see that calculating selling cost of a pizza or ice cream or determining the salary of an employee follow similar algorithms? The brilliance of a software engineer and computer scientist lays in seeing generality of an algorithm, and then observe as to which computational problems in real life, can be solved by that algorithm with minor modifications. You can think of each generic algorithm like a theorem in mathematics. Just like a theorem can be applied to many situations in real life to solve a problem, similarly a general algorithm can solve problems in fields, which do not seem to have anything in common on the surface. We will show you more generic algorithms when we have learned about loops.

Program Description:

As a paymaster for Badwater Brewery, you are asked to determine the gross pay of an employee based on the employee data that includes single letter employee code, job classification code indicated by an integer value (of 1, 2, or 3), number of years of service (whole number only), and educational code (integer value of, 1, 2, 3, or 4). Each code and years of service would affect employee gross pay in manner described in detail below. Employee data would be entered from keyboard. It is not necessary that when running program, user will always enter all codes correctly. User may make errors in entering the codes from keyboard data entry. There are more instructions regarding what to do in that case later.

Part 1 of Employee compensation comes from base pay that depends upon employee title, which is stored in data tables as employee code (S, O, or M). Table 1 shows the relationship between employee code and base pay.

Table 1: Base Pay for various Employee Codes
Employee Description Base Pay in Dollars Employee Code
Factory Worker 800.00 S
Office Worker 1000.00 O
Management 1500.00 M

Meaning of above table is as follows:

If employee code stored were uppercase S then their base pay would be $800.00. For employee codes uppercase O and M, base pay would be $1000.00 and $1500.00 respectively. If user enters a lower case code or upper case code other than S, O, and M then that is invalid code.Final Gross salary in that case is not calculable. For computation purpose you may set salary to zero when employee code is invalid. Zero salary will be displayed as “Salary not calculated”.Setting salary to zero is simply an error trapping mechanism. Other way to do that would be to set Boolean flags to true or false when each code is entered and code is valid vs invalid respectively. Calculate salary finally subject to condition when all flags are true.

To determine gross salary, a percentage of base pay is added to the base pay depending upon as to how employee fares in the three categories described further. Each category may add additional salary component towards the employee gross pay.

Category 1: Job Classification: Depending upon employee job classification, an additional component is added towards the gross salary. Use the table 2 shown on next page, to add to the base pay calculated in part 1 above.

Table 2: Additions to base pay due to Job Classification
Job Classification Percentage of base pay to add to calculate gross pay
1 5%
2 10%
3 15%
Example: If employee code is M, then from table 1, the base pay would be $1500. If job classification is 3, then 20 % of base pay (= 300) would be added to the base pay. Thus after adding this component the salary would become $1800.00

Category 2: Years of Service:

For service from 0 to 10 years, add 5% of the base pay to the salary calculation. For above 10 years of service, add 1% for each year above 10 years. Maximum service can only be 50 years. If user enters years of service negative or >50 years then that is invalid. Overall salary in that case should be set to zero, which will later be outputted as not calculated.

Example: Assume that employee code is M, job classification is 3, and years of service are 12. Then as calculated in last row of table 2, salary calculated including job classification would be $1800.00. Now for 12 years of service, for first 10 years we add 5% of base pay. Since base pay for code M is 1500, that will component will be = 1500*0.05 = 75. Extra service years are 2. We add 1% of base pay for each extra year. That will be = 1500*0.01*2 = 30. So now salary rises to: 1800 + 75 + 30 = 1905. Note that if years of service entered would have been higher than 50, then that is invalid. In that case salary would be set to zero and should stay regardless of next or previous codes.

Category 3: Educational Adjustment: Use the following table to add to the salary calculation.

Table 3: Addition to salary due to educational code
Education Code Level of Education Percentage of base pay to add to calculate the gross pay
1 High School 0%
2 Junior College 5%
3 University 12%
4 Graduate School 20%

Example: Let us carry on example we have been working out in each section. We have shown above that if employee code is M, job classification is 3, years of service are 12, then salary from first three components is $1905. Assume that education code for that employee is 2. In that we add to salary calculated so far 5% of base pay. For employee code M base pay is 1500. Thus final gross salary will become:

1905 + 0.05*1500 = 1980. This number will be displayed by program in proper format. See output example on next page for the data below.

Upon program prompt, the user data entry may be done one line (cascaded input) or in several lines in the order given by the figure below. Use string data for first name and last name.

Your program output must be of the following format. For example for the data entry shown in Figure on previous page the output would look like below.

Name ID# Job Type Gross Salary

Jack Smith 1234 Management $1980.00

……….. …….. …………… ………………

You can use setw function to create a table such as above so each subsequent output is done in field width specification passed as argument to setw function. See description of setw either in chapter 4 (Singhal CS1 e-book), Tony Gaddis textbook, or

For employees, for which the data are invalid, the program must print the message to the affect that Gross Salary could not be calculated due to bad data. The types of bad data may be:

•Employee code in lower case letter or code other than M, O, and S. Do not use toupper function to fix user input in this case. We would like to see output cases where invalid data would activate false flag values and output proper error message.

•Number of years of service exceeding 50 years

•Educational and job classification code not in the correct range.

Note: For practical convenience of data entry for me when I check your program, please DO NOT alter the order of data entry from the one shown in Figure above. Your program MUST accept data strictly in the order below:

•First Name (Use string data type. Requires #include

•Last Name (Use string data type)

Employee code (DO NOT USE string Data type)

•ID number

•Job classification code

•Years of service

•Educational code

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
The price is based on these factors:
Academic level
Number of pages
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
error: Content is protected !!