How to calculate federal and fica taxes withheld

Assignment Help Computer Engineering
Reference no: EM1332157

I wrote the following c++ code to a source file

/this program will calculate federal and fica taxes withheld and calculate net pay
//for an employee

#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;

//function prototypes

void empInput(string&, float&, float&, float&);
float calcFwt(float, float);
float calcFica (float, float);
float calcNetPay (float, float, float);
void dispEPay (string, float, float, float);

int main ()
{
string name = "";
float wkSal = 0.0;
float fedWld = 0.0;
float fedWldRate = 0.0;
float ficaWld = 0.0;
float ficaWldRate = 0.0;
float netPay = 0.0;
int howMany = 0;
int count;

cout<<"Please enter the number of employees you want to process: ";
cin>> howMany;
cin.ignore(1);

//begin loop

for (count = 1; count <= howMany; count++)
{
//enter input items

empInput(name, wkSal, fedWldRate, ficaWldRate);

//calculate fed tax

fedWld = calcFwt(wkSal, fedWldRate);

//calculate fica tax

ficaWld = calcFica(wkSal, ficaWldRate);

//calculate net pay

netPay = calcNetPay(wkSal, fedWld, ficaWld);

//display employees name pay and taxes withheld

dispEPay(name, fedWld, ficaWld, netPay);
}

return 0;
}//end of main function

//*********program defined function**********

void empInput(string& emp, float& salary1, float& tax1, float& tax2)

{
cout<<"Please enter employee's name: ";
getline(cin, emp);
cin.ignore(1);
cout<<"Please enter employee's salay: ";
cin>> salary1;
//validate
while(salary1 < 0)
{
cout<<"Salary should be a positive number: ";
cout<<"Please enter employee's salary: ";
cin>> salary1;
}
cout<<"Please enter federal income tax rate: ";
cin>> tax1;
//validate
while(tax1 < 0)
{
cout<<"The tax rate should be a positive number: ";
cout<<"Please enter federal income tax rate: ";
cin>> tax1;
}
cout<<"Please enter the fica tax rate: ";
cin>> tax2;
//validate
while(tax2 < 0)
{
cout<<"The tax rate should be a positive number: ";
cout<<"Please enter the fica tax rate: ";
cin>> tax2;
}
cin.ignore (1);
}//end of getinput function

float calcFwt(float empsal, float fedrate)
{
return empsal * fedrate;

}//end of calcfwt function

float calcFica(float salary, float ficarate)
{

return salary * ficarate;

}//end of calcFica

float calcNetPay(float esalary, float fed, float fica)
{

return esalary - fed - fica;

}//end of netpay function

void dispEPay(string employee, float fed1, float fica1, float pay)
{
cout<<"Employee's name: "<< employee << endl;
cout<<"Federal tax withheld: "<< fed1 << endl;
cout<<"FICA tax withheld: "<< fica1 << endl;
cout<<"Employee's net pay is $: "<< pay << endl;

system ("pause");
system ("cls");
}//end of dispepay function

My problem is when I run it, after I enter the employee's name, I have to push enter twice before it will say enter salary. I think I am doing something wrong w/cin.ignore

(My program really is not out of line like it shows here it just did that when i cut and pasted it)

Reference no: EM1332157

Questions Cloud

Optimization models : Which business functions are more likely to use optimization models than others and explain your answer.
Why using euler''s method is the simplest numerical method : This is being solved by computer code in c++ to obtain numerical approx to ODE. Using Euler's method is the simplest numerical process for approximation solving initial value ODE'S.
Identify 3 relevant and nonrelevant cost : Assist in Identifying three relevant and three non-relevant costs and set up a table to present the information and then discuss the information. Include the following and f you cannot identify specific actual amounts, make a reasonable estimate and ..
Build a code in preparation for creating a spell-checker : Write down a code in preparation for creating a spell-checker. For now don't worry about actually spell checking: Just write a program that can read in the dictionary word by word.
How to calculate federal and fica taxes withheld : how to calculate federal and fica taxes withheld.
Find productivity improvement by reducing materials cost : CD players are produced on an automated assembly line process. The standard cost of CD players is $150 per unit [labor $30, materials $70 and overhead $50] the sales price is USD 300 per unit.
Modify a single program using control structures : For your strength of materials course you will write down a single program using control structures(including nested loops)and file I/O to explore the deflection of the cantilever beam with a point load at the free end.
The airline industry using excel solver : During the month of July, Pittsburgh resident Bill Fly must make 4 round-trip flights between Pittsburgh and Chicago. These are the dates of the meetings Bill must attend:
How many units of the contract will the agent buy : Suppose a risk averse agent. Explain how many units of the contract will the agent buy if the price is q=k.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd