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

  Developing the java program

Write down a program in java to input the basic salary of 15 persons. Each one of them receives 25% of basic as hra (house rent allowance), 15 % of the basic as conveyance and 10 % of the basic as an entertainment allowance.

  Imagine , a computer has 2^16 bytes of main memory

imagine , a computer has 2^16 bytes of main memory. There is a direct-mapped cache of 1K lines with a line size of 4 bytes.

  Examine the process of formal software testing

examine software testing as a career path, and consider what skills would be desirable for a software tester.

  How to write a program to generate a table of factors

Write down a program to generate a table of factors used to compute monthly payments for the money borrowed.

  Data mining-data base and data warehousing

Data mining tools and models help you address? Explain each of tasks and how data mining tools and models address each. How does the data mining relate/contrast to data base and data warehousing? Whether these different or the same approaches. exp..

  Write down the normalized entities in the correct format

Write down the normalized entities in the correct format.

  Designing an inventory management system

Xhemrock is a brake pad manufacturing company. This company utilizes the raw materials, like carbon powder, ash, iron, and resin. It wishes to design an inventory management system which will have the following attributes: The system must store th..

  Explain in details what are structures

Explain in details what are structures.

  Common runtime libraries such as visual studio.net

should C++ programming language be extended to contain an XML editor and parser as is the case for the Java® programming language, or should this be built into the Integrated Development Environment (IDE) that supports the programming language?

  Suggesting the dss solution

Now you are asked to suggest a DSS solution in order to help the claim adjusters recognizes and red flag various types of fraud.

  Write a program that mimics a flop-turn-river of poker game

Write down a program that mimics a flop-turn-river of a poker game. I must have three buttons titled Deal, Shuffle and Start Over.

  Patterns may the neural network show from sources

If someone were to have a neural network that could scan information on all aspects of your life, where will  that neural network be able to find information about you.

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