Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

My Output so far:

image text in transcribed

image text in transcribed

My code so far:

#include #include #include #include #include #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 -- $ 1. The day must be exactly two digits. If the day is 1- 9, it must be 01-09 2. The 3-character month must be the three-character month: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, or Dec. 3. The year is simply a 2 or 4 digit year. If the year is only two digits, assume the 21st century For example, year 10 will be the year 2010 4. The citation is exactly the citation given in the input file, but it will be in a left justifhed field 10 characters wide. 5. The $ must follow the citation field 6. The fine will be a dollar amount in a right justified field, 9 characters wide. 7. You will only output those citations that occur between the given report start date and end dates (inclusively). Example Valid input example: /lab6 Enter a ticket file: ticket Enter a report file: output Enter report start date (mm dd yyyy): 7 1 2017 Enter report end date Cmm dd yyyy): 8 11 2018 ticket file contains: E059564 8 12 2018 89 55i E515522 7 3 2017 105 50 r E712221 6 4 2015 200 25 h E219221 12 25 17 2000 10 p output file contains: 03-Jul-2017 E515522 943.39 25-Dec-2017 E219221 24182.48 Missing file example: lab6 Enter a ticket file: somebadfilename Unable to open somebadfilename. Submission Compile your code using the following g++ -Wall -00 -g -std-c++11 - lab lab.cpp Submit your .cpp file. Mini Lab Solution #include using namespace std; int main) int syear, smonth, sday: int eyear, emonth, eday: int cyear, onth, cday; cout >syear >>smonth sday cout emonth >eday: cout cmonth cday int start syear * 1 + smonth * 10 + sday; int endeyear 10000 +emonth100 eday; int check cyear10000 cmonth 100 cday; if (check > start && check -- $ 1. The day must be exactly two digits. If the day is 1- 9, it must be 01-09 2. The 3-character month must be the three-character month: Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, or Dec. 3. The year is simply a 2 or 4 digit year. If the year is only two digits, assume the 21st century For example, year 10 will be the year 2010 4. The citation is exactly the citation given in the input file, but it will be in a left justifhed field 10 characters wide. 5. The $ must follow the citation field 6. The fine will be a dollar amount in a right justified field, 9 characters wide. 7. You will only output those citations that occur between the given report start date and end dates (inclusively). Example Valid input example: /lab6 Enter a ticket file: ticket Enter a report file: output Enter report start date (mm dd yyyy): 7 1 2017 Enter report end date Cmm dd yyyy): 8 11 2018 ticket file contains: E059564 8 12 2018 89 55i E515522 7 3 2017 105 50 r E712221 6 4 2015 200 25 h E219221 12 25 17 2000 10 p output file contains: 03-Jul-2017 E515522 943.39 25-Dec-2017 E219221 24182.48 Missing file example: lab6 Enter a ticket file: somebadfilename Unable to open somebadfilename. Submission Compile your code using the following g++ -Wall -00 -g -std-c++11 - lab lab.cpp Submit your .cpp file. Mini Lab Solution #include using namespace std; int main) int syear, smonth, sday: int eyear, emonth, eday: int cyear, onth, cday; cout >syear >>smonth sday cout emonth >eday: cout cmonth cday int start syear * 1 + smonth * 10 + sday; int endeyear 10000 +emonth100 eday; int check cyear10000 cmonth 100 cday; if (check > start && check

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+13.5. Show of real functions f and g that f(w) + g(w)

Answered: 1 week ago

Question

Explain the pages in white the expert taxes

Answered: 1 week ago