The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 304 Weeks Ago, 2 Days Ago |
| Questions Answered: | 15833 |
| Tutorials Posted: | 15827 |
MBA,PHD, Juris Doctor
Strayer,Devery,Harvard University
Mar-1995 - Mar-2002
Manager Planning
WalMart
Mar-2001 - Feb-2009
c++ PROGRAM HELP, BEGINNER
Â
Below is what I'm working on, I've already done 3A. Now I'm working on the rest. the program that I'm working with is attached to the bottom of the page as well as the small table of data relevant to the program.
Â
Â
M2 Written Assignment - Loops and Ifs
PAYROLL SYSTEM PHASE 3: LOOP
The main purpose of this phase is to get accustomed to the repetition of a program using a loop and reading data interactively as well from an external file.
Hint: Use a while loop.
3A. ALREADY DONE.
                       ………….…………..
3B) Expand your Payroll program so that it repeats for as many employees are in the input file.
Data typed and saved under employee.in
Use:
#include
#include
using namespace std;
…….
ifstream fin("employee.in");
………
while(fin>>employeeid>>hoursworked>>hourlyrate){…….…..}//end loop
PAYROLL SYSTEM PHASE 4: DECISION-MAKING
In this phase of the payroll system, we are going to include the appropriate tax rate (variable) rather than a fixed tax rate of 10% (constant). The program will also compute the overtime pay.
4A) Assign different tax rates based on the following gross pay:
The tax rate will also vary based on marital status. Add 5% to the tax rate of a single person and subtract 5% if head of household.
Declare marital status as a character:Â S=Single M=Married H=Head of Household
Program should accept either upper case or lower case letters for marital status (e.g. accept M or m).
4B) Compute the overtime pay according to the following formula:
Any hours over 40 are considered time and a half (overtime).
You may want to find overtime hours (e.g. hoursworked – 40) and overtime pay (e.g. overtimehours*hourlyrate * 1.5).
You should submit a copy of your program.
You should also paste a copy of your output and document your program and submit it as a Word document.
Â
Â
Â
This is what I have now. It's failing in my compiler and after 4 hours, I can't get it to work in either of my computers. I have numerous compilers, Dev C++, Codeblocks (my preferred) as well as Turbo C.
Â
Â
#include <iostream>
#include <fstream>
using namespace std;
   int main(){
   ifstream input; //file for opening input info for employee data
   input.open ("employee.txt")//create the file for review after completion
Â
   int numberofemployees;
   int employeeid, hoursworked;
float hourlyrate, grosspay, taxamount, netpay;
Â
const float TAXRATE = 0.20;
Â
numberofemployees = 0;
Â
while( input>>employeeid>>hoursworked>>hourlyrate ){
grosspay=hoursworked*hourlyrate;
taxamount=grosspay*TAXRATE;
netpay=grosspay-taxamount;
Â
Â
cout << "Thank You for working at Dr. Ebrahimi.com Inc.!" <<;
cout << "EMPLOYEE ID IS"<<employeeid << endl;
cout << "THE HOURS WORKED ARE"<<hoursworked<< endl;
cout << "THE HOURLY RATE IS"<<hourlyrate<<endl;
cout << "YOUR GROSSPAY IS"<<grosspay << endl;
cout << "YOUR TAX AMOUNT IS"<<taxamount<<endl;
cout << "YOUR NETPAY IS"<<netpay<<endl<<endl;
numberofemployees = numberofemployees + 1;
}//WHILE
input.close ();//close the before created file
system("PAUSE");
return 0;
}//MAIN
Â
 EMPLOYEE DATA INFO FOR TEXT FILE
1645Â Â Â 10Â Â Â 9.99
8932Â Â Â 40Â Â Â 20.00
7104Â Â Â 20Â Â Â 15.99
2816Â Â Â 15Â Â Â 50.00
5387Â Â Â 30Â Â Â 6.99
----------- Â ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly