c++
Project 10-2: Miles Per Gallon Calculator The program should first invoke a function display_file_data0 to read all the trips of miles driven and gallons of gas used from a file named "trips.txt", calculate the corresponding value of miles per gallon (MPG) for each trip, and display miles, gallons and MPG of each trip in the console followed by the statistical results of total miles, total gallons and average MPG. Next, the program should ask the user to provide inputs of newv miles and gallons respectively, calculate the corresponding MPG and store the new miles and gallons into the same file "trips. txt' as a new trip. Lastly, the program invokes the function display file data0 again to reflect the updated file content and statistical results. Code for MPG calculation should also be in another function calculate_mpg(double, double) Note: Bold words are output while non-bold words are input in the following console sample. The trips.txt file (the 2 columns are miles driven and gallons of gas used respectively, aligned with tabs) Specifications - Your program should be able to handle the situation when file "trips txt" doesn't exist. - Miles and gallons (both in console or file) should show only 1 decimal place while mpg keeps 2 decimal places. - Miles should occupy 8 characters while both gallons and mpg occupy 12 characters. - Average mpg can be obtained by dividing total miles with total gallons. - Total miles, total gallons and average mpg printed in the console should show 2 decimal places. - The first column showing the text of total miles, total gallons and average MPG should be left-justified and occupy 15 characters while the second column showing the corresponding values should be right-justified and occupy 10 characters. - If miles driven is smaller than zero, you program should keep asking for another attempt of input from the user with the error message "Miles driven must be greater than zero. Please try again." - If gallons of gas used is smaller than zero, you program should keep asking for another attempt of input from the user with the error message "Gallons of gas used must be greater than zero. Please try again." - Every trip of miles and gallons separated with a tab character occupies a whole line in file "trips.txt". - Your program should always repeat until it receives a character other than y or X. - The 2 functions display_file_data0 and calculate_mpg(double, double) must be created accordingly. Project 10-2: Miles Per Gallon Calculator The program should first invoke a function display_file_data0 to read all the trips of miles driven and gallons of gas used from a file named "trips.txt", calculate the corresponding value of miles per gallon (MPG) for each trip, and display miles, gallons and MPG of each trip in the console followed by the statistical results of total miles, total gallons and average MPG. Next, the program should ask the user to provide inputs of newv miles and gallons respectively, calculate the corresponding MPG and store the new miles and gallons into the same file "trips. txt' as a new trip. Lastly, the program invokes the function display file data0 again to reflect the updated file content and statistical results. Code for MPG calculation should also be in another function calculate_mpg(double, double) Note: Bold words are output while non-bold words are input in the following console sample. The trips.txt file (the 2 columns are miles driven and gallons of gas used respectively, aligned with tabs) Specifications - Your program should be able to handle the situation when file "trips txt" doesn't exist. - Miles and gallons (both in console or file) should show only 1 decimal place while mpg keeps 2 decimal places. - Miles should occupy 8 characters while both gallons and mpg occupy 12 characters. - Average mpg can be obtained by dividing total miles with total gallons. - Total miles, total gallons and average mpg printed in the console should show 2 decimal places. - The first column showing the text of total miles, total gallons and average MPG should be left-justified and occupy 15 characters while the second column showing the corresponding values should be right-justified and occupy 10 characters. - If miles driven is smaller than zero, you program should keep asking for another attempt of input from the user with the error message "Miles driven must be greater than zero. Please try again." - If gallons of gas used is smaller than zero, you program should keep asking for another attempt of input from the user with the error message "Gallons of gas used must be greater than zero. Please try again." - Every trip of miles and gallons separated with a tab character occupies a whole line in file "trips.txt". - Your program should always repeat until it receives a character other than y or X. - The 2 functions display_file_data0 and calculate_mpg(double, double) must be created accordingly