(Gas Mileage) Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several trips by recording miles driven and gallons used for each trip. Develop a C++ program that uses a while statement to input the miles driven and gallons used for each trip. The program should calculate and display the miles per gallon obtained for each trip and print the combined miles per gallon obtained for all tankfuls up to this point.
The input consists of n (0<n<100) lines.
Each line consists of int_A(miles), int_B(gallons).
The last line of input consists of int(-1).
The decimal precision of output is 6.
输入
51 5
51 50
34 5
61 89
-1
输出
MPG this trip: 10.200000
Total MPG: 10.200000
MPG this trip: 1.020000
Total MPG: 1.854545
MPG this trip: 6.800000
Total MPG: 2.266667
MPG this trip: 0.685393
Total MPG: 1.322148
You can use "setprecision()" and "fixed" to set the decimal precision of output. Use float to declare data.