Question: C + + , data analysis program, This program will read from a file called automobile.csv , gathers the data and find out which car
C data analysis program,
This program will read from a file called automobile.csv gathers the data and find out which car has the highest horsepower and lowest displacement.
automobile.csv data:
names displacement horsepower
chevrolet chevelle malibu
buick skylark
plymouth satellite
amc rebel sst
ford torino
ford galaxie
I wrote a part of the program, but it doesn't work properly. my program is as follows:
#include
#include
#include
#include
using namespace std;
const int ITEMS ;
const int MAXCHAR ;
function prototypes
void welcome;
void openFileifstream& inFile, char fileName;
void openFileofstream& outFile, char fileName;
int readDataifstream& inFile, char namesMAXCHAR double displacement double horsepower;
void printDatachar namesMAXCHAR double displacement double horsepower int count;
void printDatachar nameMAXCHAR double displacementdouble horsepower int count, ofstream& outFile;
int main
ifstream inFile;
ofstream outFile;
char fileNameMAXCHAR;
double displacementITEMS;
double horsepowerITEMS;
char namesITEMSMAXCHAR;
inFile.opendatatxt;
int count ;
welcome;
cout
Please enter the input file name: endl;
cin.getlinefileName MAXCHAR;
call the function
openFileinFile fileName;
strcpyfileName "output.txt;
openFileoutFile fileName;
call read data function
count readDatainFile names, displacement, horsepower;
call the print data function
printDatanames displacement, horsepower, count;
printDatanames displacement, horsepower, count,outFile;
return ;
void welcome
cout "Welcome to my Fun Data Analysis Program endl;
cout
This program will read from a file called automobile.csv gathers the data to find out which car has the highest horsepower and lowest displacement.";
void openFileifstream& inFile, char fileName
inFile.openfileName;
ifinFile
cout "File did not open! Program terminating!!" endl;
exit;
void openFileofstream& outFile, char fileName
outFile.openfileName;
ifoutFile
cout "File did not open! Program terminating!!" endl;
exit;
int readDataifstream& inFile, char namesMAXCHAR double displacement double horsepower
int count ;
while inFile.eof
inFile namescount displacementcount horsepowercount;
count;
inFile.close;
return count;
void printDatachar namesMAXCHAR double displacement double horsepower int count
cout fixed showpoint setprecision;
for int i ; i count; i
cout namesi displacementi horsepoweri endl;
cout endl;
void printDatachar nameMAXCHAR double displacementdouble horsepower int count, ofstream& outFile
outFile fixed showpoint setprecision;
for int i ; i count; i
outFile namei displacementi horsepoweri endl;
outFile.close;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
