there's something wrong with my program, it runs but it goes on forever and it doesn't display the day of the week only the letter M and that's it
this is my text file, but my program is not suppose to be restricted to this text file:
Monday Tuesday Wednesday Thursday Friday Saturday Sunday
34252 85776 65746 93453 63534 34335 0
78352 23412 89889 88387 48021 89903 0
98098 73495 12489 84895 30583 28423 0
28942 38942 38475 83753 83729 82742 0
PLEASE HELP!!!! thank you
#include <iostream>
#include <fstream>
using namespace std;
int weightFunction(int, int);
int main(){
//open input file
ifstream inFile;
inFile.open("Trucks.txt");
if(!inFile){
cout<<"Can't open file";
return 1;
}
//write to file
ofstream outFile;
outFile.open("TruckFines.txt");
//variables
string dayOfWeek;
int truckWeight, currentWeight, currentDays, currentTruck, currentTruckWeight, result;
int i, n, d/* day # */,t/* truck #*/, g;
//for loop for inFile
for (i = 0; i < 7; i++){
inFile >> dayOfWeek[i];
}
while (inFile){
for (n = 0; n < 7; n++){
inFile >> currentDays;
}
}
//for loop for day
for (d = 0; d < 7; d++){
outFile << "Data for " << dayOfWeek[d]<< ":" << endl;
outFile << "Trucks with Fines: " << endl;
//for loop for trucks
for (t = 0; t < truckWeight; t++) {
currentTruckWeight = truckWeight;
//function call
result = weightFunction (d, t);
outFile << "Truck# " << currentTruck + 1 << " $" << result << endl;
outFile << endl;
outFile << "Trucks without fines: " << endl;
//goes through all trucks
for(g = 0; g < truckWeight; g++){
currentWeight = truckWeight;
//if current truck is less than or equal to the weight limit
if(currentWeight <= 80000){
outFile << "Truck# " << currentTruck + 1 << endl;;
}
}
outFile << endl;
}
}
system("pause");
return 0;
}
//function for overweight limit
int weightFunction(int d, int t){
//variables
int currentDay, currentTruck, currentWeight, result;
//if current truck over limit (limit is 80,000)
if (d > 80000){
result <<((currentWeight - 80000) % 100) * 50;
}
return result;
}