Can someone help me with this? I don't know why my code wont run...

My program will prompt the user for an input file that contains one line for
each person to whom the Company provided service. Each line has the following
values, separated by commas:

The last name of the person (string value)
The first name of the person (string value)
The hourly rate used (float value)
The total consulting time in minutes (int value)
The person’s income (float value)

For example, input lines may look something like:
Smith, John, 70.50, 32, 10000.00
Rhys David, Jennifer, 45.00, 56, 75432.10

Then my program has to do the math and get an answer then prompted the user with something like this:

Enter input file name: input.txt
Total Charges: $ 2353.00
Average Charge: $ 127.60

This is my code:[/b]


#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cerrno>
#include <cstring>
#include <cmath>
using namespace std;

//Function declarations
string getFileName(ios_base::open_mode);
bool isLowIncome();
int calculateCharge;
int lineCounter();

int main(int argc, char **argv)
{
//Local variables
fstream inFile; //Files
string buffer, inName; //Strings

//Processing
inName = getFileName(ios::in);
inFile.open(inName.c_str());
getline(inFile, buffer, '\0');
inFile.clear();
inFile.close();
int charge;
calculateCharge = charge;
cout << "Total charges: " << calculateCharge << endl;


return 0;
}


string getFileName(ios_base::open_mode mode) {

string fileBuffer;
string myString;
fstream inFile;
string outString;
string editedInput;

cout << "Enter input file name: ";
getline(cin, myString);

inFile.open(myString.c_str(), ios::in);
if (!(inFile.good())) {
cout << "Unable to open input or output file" << endl;
return 0;
}
getline(inFile, fileBuffer, '\0');

inFile.close();
return myString;
}

bool isLowIncome(string myString){
string last, first;
int time;
float rate, income;
istringstream inStream;
bool incomestatus;
inStream.str(myString);
getline(inStream, last, ',');
getline(inStream, first, ',');
inStream >> rate;
inStream >> time;
inStream >> income;
inStream.clear();

if (income <= 25000)
incomestatus = 1;
else
incomestatus = 0;


return incomestatus;
}
float totalCharge(bool isLowIncome(string), bool incomestatus){
string last, first;
int time;
float rate, income;
istringstream inStream;
string myString;
inStream.str(myString);
getline(inStream, last, ',');
getline(inStream, first, ',');
inStream >> rate;
inStream >> time;
inStream >> income;
inStream.clear();
double charges;

if (incomestatus)
if (time <= 30)
charges = 0.0;
else
charges = rate*0.4*(time - 30) / 60;
else if (time <= 20)
charges = 0.0;
else
charges = rate*0.7*(time - 20) / 60;
return charges;

}


Topic archived. No new replies allowed.