This is my assignment
Assignment #16 due 5/14
Gas comparison cost of various cars.
A company has five cars that give varying gas mileages of 10, 15, 20, 25 and 30 MPG. Assume that the cars were driven 10000, 15000, 20000, 25000 and 30000 miles per year respectively, and the cost of one gallon of gas is $2.75. Write a program to display a two-way table of the annual cost rounded to 2 decimal places. Display the MPG across as columns and the miles as rows and the appropriate headings as follows:
M P G
Miles 10 15 20 25 30
10000: $ 2750.00 $ 1833.33 $ 1375.00 $ 1100.00 $ 916.67
15000: $ 4125.00 $ 2750.00 $ 2062.50 $ 1650.00 $ 1375.00
20000: $ 5500.00 $ 3666.67 $ 2750.00 $ 2200.00 $ 1833.33
25000: $ 6875.00 $ 4583.33 $ 3437.50 $ 2750.00 $ 2291.67
30000: $ 8250.00 $ 5500.00 $ 4125.00 $ 3300.00 $ 2750.00
Press any key to continue . . .
This is what I did
#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
const double gas=2.75;
double price;
On my program I only made a nested for loop to test the calculations are correct.
But when I run the program, instead of listing the prices of 10MPG column, it listed the prices for the 30MPG.
How can I fix my program to show the table that my professor wanted?