COMP122 Week 2 iLab - Payroll and Right Triangle Program

A week 2 iLab focusing on creating a payroll program and solving right triangle problems using C++.

Daniel Kim
Contributor
4.9
59
5 months ago
Preview (3 of 9 Pages)
100%
Purchase to unlock

Page 1

COMP122 Week 2 iLab - Payroll and Right Triangle Program - Page 1 preview image

Loading page image...

1COMP122 Week 2 iLab-Payroll and Right Triangle ProgramCOMP122Week2iLabCompletethe following two programs:Programming Problem 1Write a program that calculates and outputs the monthly paycheck information for anemployee, including all theamounts deducted from an employee’s gross pay, and the netpay that is due to the employee. The user of your program will knowtheemployee’sname and the gross payfor the employee. Each employee has the following deductionstaken from his gross pay:Federal Income Tax:15%State Tax:3.5%Social Security + Medicare Tax:8.5%Health Insurance$75The output from your program should be structuredas is displayed below:BillRobinsonGrossAmount:............$3575.00Federal Tax:.............$536.25StateTax:............... $125.13Social Sec / Medicare:... $ 303.88Health Insurance: ........ $75.00NetPay: ................. $2534.75Your program should deal with erroneous input values. Gross salary should always be apositive number. Make sure that you deal with the possibility that the user may haveentered a non-numeric input value. Have your program output appropriate error messagesin these cases.1. Identify the inputs and outputs of theproblem.Employee name (string)Gross pay (positive numeric value)Outputs:Employee name (string)Gross payFederal Tax (15% of gross pay)

Page 2

COMP122 Week 2 iLab - Payroll and Right Triangle Program - Page 2 preview image

Loading page image...

Page 3

COMP122 Week 2 iLab - Payroll and Right Triangle Program - Page 3 preview image

Loading page image...

2State Tax (3.5% of gross pay)Social Security + Medicare Tax (8.5% of gross pay)Health Insurance ($75)Net pay (gross pay minus deductions)2. Identify the processing needed to convert the inputs to the outputs.Processing Steps:1.Take the employee name and gross pay as input.2.Validate that the gross pay is a positive number. If not, display an error.3.Calculate the deductions:oFederal tax = 15% of gross payoState tax = 3.5% of gross payoSocial Security + Medicare tax = 8.5% of gross payoHealth insurance = $75 (fixed value)4.Subtract the total deductions from the gross pay to get the net pay.5.Output theemployee’s name and all calculated values in the specified format.3. Design an algorithm in pseudocode to solve the problem. Make sure to include steps toget each input and to report each output.Include steps to deal with error cases.StartPrompt user for employee nameInput employee namePrompt user for gross payInput gross payIf gross pay is not a positive numberDisplay "Error: Gross pay must be a positive number."End programCalculate federal_tax = gross pay * 0.15Calculate state_tax = gross pay * 0.035Calculate social_security_medicare = gross pay * 0.085Set health_insurance = 75.00Calculate total_deductions = federal_tax + state_tax +social_security_medicare +health_insuranceCalculate net_pay = gross pay-total_deductions
Preview Mode

This document has 9 pages. Sign in to access the full document!

Study Now!

XY-Copilot AI
Unlimited Access
Secure Payment
Instant Access
24/7 Support
Document Chat

Document Details

Related Documents

View all