Question
URGENT- I need help revising my c++ code to match the example and to allow me to open the file. Please follow the example as
URGENT- I need help revising my c++ code to match the example and to allow me to open the file. Please follow the example as closely as possible and follow all instructions. ALSO TELL ME WHERE YOU MADE CHANGES IN THE CODE AND WHY. ALSO POST A SCREENSHOT OF THE CORRECT OUTPUT ON YOUR END AFTER YOUVE COMPLIED THE CODE! THANK YOU.
Assignment & Example
My Output so far:
My code so far:
#include
using namespace std;
//structure to store date struct date { int month; int day; int year; };
bool isValid(date d); //method to check date valid or not bool isDateInRange(date d,date start,date end); //method to check if date is with in range
int main() { //constants we use in this const double INTERSTATE = 5.2252; const double HIGHWAY = 9.4412; const double RESIDENTIAL = 17.1525; const double OTHER = 12.152; const string months[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
string inputfile,outputfile; //string to store filename cout > inputfile; //taking input cout > outputfile; //taking input
string dateraw; date start,end; cout >start.month>>start.day>>start.year; //verifying date if(!isValid(start)) { cout
cout >end.month>>end.day>>end.year; //verifying date if(!isValid(end)) { cout
ifstream inFile(inputfile); //creating if stream object to read file ofstream outFile(outputfile);//creating out stream object to write file if (!inFile.is_open()) //handling if file not found { std::cout
string cnum; int month,day,year; double speed,splimit; char road;
cout >cnum>>month>>day>>year>>speed>>splimit>>road) //loop till end of file && collect data { if(year
//using switch case for different fines switch(toupper(road)) { case 'I': { fine = diff * INTERSTATE; break; } case 'R': { fine = diff * RESIDENTIAL; break; } case 'H': { fine = diff * HIGHWAY; break; } default: { fine = diff * OTHER; break; } }
//writing data into file outFile
}
//closing files inFile.close(); outFile.close(); cout
//method to check if given date is valid //takes struct type date parameter bool isValid(date d) { int month=d.month, day=d.day, year=d.year;
if ((month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) && ( day>31 || day30 || day29 || day28 || day 10000)) { return false; } if ((month 12)) { return false; } return true; }
//checks if date d is in between start and end //here using logic : convert 12/31/1992 = 19921231 //and then comparing bool isDateInRange(date d,date start,date end){ //converting each date into 8 digit number int entryDate = (d.year * 10000) + (d.month * 100) + d.day; int startDate = (start.year * 10000) + (start.month * 100) + start.day; int endDate = (end.year * 10000) + (end.month * 100) + end.day;
/ow comparing if (entryDate >= startDate && entryDate Lab 6 Submit Assignment Due Wednesday by 8am Points 100 Submitting a file upload File Types cpp Available Feb 13 at 8am - Mar 1 at 8am 16 days Assignment You will be developing a speeding ticket fee calculator. This program will ask for a ticket file, which is produced by a central police database, and your program will output to a file. Furthermore, your program will restrict the output to the starting and ending dates given by the user. The ticket fee is calculated using four multipliers, depending on the type of road the ticket was issued: Interstate multiplier: 5.2252 Highway multiplier: 9.4412 Residential multiplier: 17.1525 None of the above 12.152 The multiplier is multiplied to the difference between the speed limit and the clocked speed to determine the fine's dollar amoun Console User Interaction You must ask the user on the console for an input ticket file, an output report file, a report starting date, and a report ending date. The following prompts must be used: "Enter a ticket file:" "Enter a report file:" Enter report start date (mm dd yyyy):" Enter report end date (mm dd yyyy): Input File Format Each line will contain the following information scitation numbers
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started