Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help finishing the following code, and the only part thatcan be edited is

ID: 3613389 • Letter: I

Question

I need help finishing the following code, and the only part thatcan be edited is the part in red, nothing else can be changed:

Inside the DJI.txt file is the following:

----------------CODE----------------

/* 2170_1_5 : file_io_while_review
/* Problem description: The text file DJI.txt contains the information of a stock market index --
    Dow Jones Industrial Average Index (DJI for short) -- for a continuous time
    in year 2008. Each line contains the date and the DJI's value on that day.
    For the format of the file, please view DJI.txt.
    
    Please write a program that reads DJI values stored in the data file DJI.txt,
    and finds out the date with highest DJI value during this period stored in the file.
*/

#include <string>
#include <iostream>
#include <fstream>
using namespace std;

int main( )
{
    const string    inputFile = "/var/www/html/programs2/2170_1_5/dataFiles/DJI.txt";
    ifstream          ifs;        //an input file stream
    
    int             day;        //Today's day
    int             maxDay;        //The day of the date with max. DJI
    string        month;        //Today's month
    string        maxMonth;    //The month of the date with max. DJI
    double      maxDJI;        //The max. DJI value got so far.
    double       dji;        //Today's DJI

    ifs.open( inputFile.c_str() );    //open the file

CODE GOES HERE ONLY, CODE GOES HERE ONLY


   ifs.close();    //close the input file
    
    cout << "DJI is highest on " << maxMonth << " " << maxDay << " with " << maxDJI << endl;          

    return 0;
}

--------------END OF CODE---------------------

Explanation / Answer

please rate - thanks the system("pause"); was needed for my compiler, get rid of it ifyou don't need it #include #include #include using namespace std; int main( ) {const string    inputFile = "DJI.txt";     //const string    inputFile ="/var/www/html/programs2/2170_1_5/dataFiles/DJI.txt";    ifstream         ifs;        //an input filestream       int            day;        //Today's day    int            maxDay;        //The day of thedate with max. DJI     string       month;        //Today'smonth     string       maxMonth;    //The month of the date with max.DJI     double     maxDJI;        //The max. DJIvalue got so far.     double      dji;        //Today's DJI     ifs.open( inputFile.c_str() );   //open the file ifs>>maxMonth>>maxDay; ifs.ignore( 5,':'); ifs>>maxDJI; ifs>>month; while(ifs)       {ifs>>day;        ifs.ignore( 5,':');        ifs>>dji;        if(dji>maxDJI)            {maxMonth=month;            maxDay=day;            maxDJI=dji;            }         ifs>>month;          }     ifs.close();    //close the inputfile        cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote