Calculate federal and fica taxes withheld and calculate net

Assignment Help C/C++ Programming
Reference no: EM13938676

/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

Reference no: EM13938676

Questions Cloud

Potential for formal economic co-operation of djibouti : Q: Identify the potential for formal economic co-operation of Djibouti (Djibouti, officially the Republic of Djibouti, is a country located in the Horn of Africa) with other nations through relevant trade groupings.
What is interest group : A(n) _____ is a group of political activists who organize to win elections, operate the government, and determine public policy. An interest group is
What factors may lead to the development of gastritis : Is this acute or chronic gastritis? What factors may lead to the development of gastritis? What investigation should be performed?
Impact of globalisation on ones own life and the country : Explain the impact of globalisation on one's own life and the country. - It must be written in a reflective manner. Consider how modernisation and growth has affected the consumption behaviour, the thoughts, and have one seen evidences of changes ..
Calculate federal and fica taxes withheld and calculate net : /this program will calculate federal and fica taxes withheld and calculate net pay//for an employee
List two possible clinical diagnoses : What additional tests will the doctor order? List two possible clinical diagnoses. Explain your answer. What are some possible treatments for each of the diagnoses?
Understanding of international business : This assignment is therefore an important piece of work. It is an opportunity to demonstrate your understanding of International Business and the relevant issues raised in the assignment question(s).
Which ventricle operates under the most pressure : What would the heart do to compensate for the pressure problem created by a ventricle hole? Hint: People with this abnormal hole must have it repaired while they are young or they won't live long.
Trade is self-eliminating : What is wrong with the following statement: "Trade is self-eliminating. Opening up trade opportunities drives prices and costs into equality between countries. But once prices and costs are equalized, there is no longer any reason to trade the produc..

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create class has three pieces of information as data members

Create a class called Date in C++ that includes three pieces of information as data members: month (type int), day (type int) and yaer (type int).

  Design is known, what advantages does keeping

Given that the design is known, what advantages does keeping the source code unavailable give the company and those who purchase the software? What disadvantages does it cause?

  Implement a point class for two-dimensional points

Implement a Point class for two-dimensional points (x, y). Include a default constructor, a copy constructor, a negate() function to transform the point into its negative, a norm() function to return the point's distance from the origin (0,0), an..

  Write a program the contains an array of 1000 elements name

Write a function named equals() that accepts two char arrays and return true if both arrays have the same characters in the same order. The function should return false otherwise. Write a simple main() function to test your function.

  Write a program that contains a main function

Write a program that contains a main function and three other functions that will return various attribute information about an array of floating point

  Implement a second-order low-pass filter

Implement a second-order low-pass filter using the finite difference method. The finite difference method is a useful mathematical method that is used to numerically solve differential equations.

  Prepare a program for a retail-mart company

Prepare a program for a company Retail-Mart.

  Write a set of nested loops that display 10 rows

Write a set of nested loops that display 10 rows of # characters. There should be 15 # characters in each row.

  Program to read in the number of a month

Program to read in the number of a month and output the name of the month. Then the user is asked if they want to know the number of days in that month and if so output the number of days

  Write a recursive method fibonacci that returns

Write a recursive method Fibonacci that returns the nth Fibonacci number when passed the argument n and Write a non-recursive version of the method Fibonacci.

  Accomplish the preceding task

However, the customer details maintenance application crashed as Dwayne mistakenly entered the wrong file path. Therefore, he asks Elina to modify the application so that it does not crash due to similar errors. Modify the code that Elina needs to ..

  Implementation of the recursive algorithm

Develop an iterative method having the same functionality as the recursive nextPermutation method - Create a class SortingFunctions.

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