Trying EVERYTHING but I don't know what the *heck* I'm even supposed to try because there shouldn' tbe a *bleeping* PROBLEM. The file is being opened fine, I guess, because I tried changing the file path and then got an error. It's just not reading the DATA. THERE'S NO REASON FOR THIS. ALL THE VALUES ARE COMING TO ZERO. HERE IS THE DATA:
2 3 50
2 1 75
2 0 40
1 3 25
1 5 10
2 6 50
2 8 300
6 3 100
2 0 30
2 2 10
1 6 100
2 4 30
2 6 200
1 5 10
1 6 100
HERE IS THE CODE:
#include <iostream>
#include <cmath>
#include <iomanip>
#include <fstream>
using namespace std;
void printStock (int v[],int n);
double Sales (int v[], int n, double cost);
int main ()
{
int transtype, autonumb, units, i;
int inv[10]={0,0,0,0,0,0,0,0,0,0};
for (i=0; i<10; i++)
printStock(inv,i);
ifstream transInfo;
transInfo.open("transinfo.txt");
if(!transInfo.is_open()) {
cout << "File was not opened correctly" << endl;
cout << "program halted";
return 0;
}
transInfo >> transtype >> autonumb >> units;
cout << transtype << autonumb << units;
while (transInfo){
// (i=0; i<10; i++)
// inv[i]=i;
cout << autonumb;
if (transtype==1){
if (inv[autonumb]>=units){
inv[autonumb]-=units;
cout << "Sell " << units << " units of car " << autonumb << endl;
}
else cout << "REJECTED: Insufficient Stock" << endl;
}
else if (transtype==2){
inv[autonumb]+=units;
cout << "Receive " << units << " units of car " << autonumb << endl;
}
else cout << "INVALID TRANSACTION CODE" << transtype << endl;
transInfo >> transtype >> autonumb >> units;
}
cout << endl;
for (i=0; i<10; i++)
printStock(inv,i);
cout << "\n\nTotal potential income: " << Sales(inv,10,10000) << endl;
transInfo.close();
return 0;
}
void printStock (int v[], int n) {
cout << n << " " << v[n] << endl;
return;
}
double Sales (int v[], int n, double cost) {
int autos=0;
for (int i=0; i<n; i++)
autos+=i;
double val=autos*cost;
return val;
}
WHAT THE ??