I am taking my first computer programming course in C++ this semester. I keep getting the same errors on my program below and I do not know how to fix it. The task in this program is to open a file with names, IDs, pay rates, and benefits and to calculate the taxes paid for each individual, and then subtract the taxes and benefits from weekly earnings and to produce a table in an output file. I keep getting the following two errors when I try to compile the program:
warning C4244: '=' : conversion from 'double' to 'float', possible loss of data
error C2062: type 'float' unexpected
My code is below:
//COMP 140
//Project 3
//Due March 26, 2009
//Report Writer - Display employee information and tax rates.
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
void header();
float detail(char firstname[20], char lastname[20], int ID, float payrate, int number);
float benefit(int number);
int _tmain(int argc, _TCHAR* argv[])
{
ifstream infile;
ofstream outfile;
char firstname[20];
char lastname[20];
int ID;
int number;
float payrate;
float taxtotal=0.0;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
infile.open("MASTER[1].txt");
outfile.open("MASTEROUTPUT.rtf");
infile >> firstname >> lastname >> ID >> payrate >> number;
header();
while(infile)
{
cout << firstname << setw(5) << lastname << setw(5)<< ID;
float detail(char firstname[20], char lastname[20], int ID, float payrate, int number);
}
infile.close();
outfile.close();
cout << "The total tax paid by employees is " << taxtotal <<endl;
return 0;
}
float detail(char firstname[20], char lastname[20], int ID, float payrate, int number)
{
float tax;
float taxtotal=0;
float weekly = (40*payrate);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
tax = (.28*weekly);
int linecount;
linecount = 0;
float takehome;
using namespace std;
float q = float benefit(int number);
takehome = weekly-tax-q;
linecount++;
if(linecount > 15)
{
ofstream outfile;
outfile << "\f";
header();
linecount = 0;
}
#include <iomanip>
cout << setw(5) << weekly << setw(5) << tax << setw(5) << takehome;
ifstream infile;
infile >> firstname >> lastname >> ID >> payrate >> number;
return (taxtotal = taxtotal+tax);
}
void header()
{
using namespace std;
cout << "First Name";
cout << setw(10) << "Last Name" << setw(10) << "ID" << setw(10) << "Wages";
cout << setw(10) << "Taxes" << setw(10) << "Take Home" <<endl;
}
float benefit(int number)
{
float cost;
if(number = 0)
{
cost = 0.00;
}
if(number = 1)
{
cost = 8.00;
}
if(number = 2)
{
cost = 11.00;
}
if(number = 3)
{
cost = 13.00;
}
return(cost);
}
Thank you!

New Topic/Question
Reply




MultiQuote



|