Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to compute the Mileage given by a vehicle. Mileage = (new_odomet

ID: 3700177 • Letter: W

Question

Write a program to compute the Mileage given by a vehicle.
Mileage = (new_odometer – old_odometer)/(gallons_gas)
***illustrating how ‘for’ loop works.
This program needs to work with Microsoft visual studio!
Write a program to compute the Mileage given by a vehicle.
Mileage = (new_odometer – old_odometer)/(gallons_gas)
***illustrating how ‘for’ loop works.
This program needs to work with Microsoft visual studio!
Write a program to compute the Mileage given by a vehicle.
Mileage = (new_odometer – old_odometer)/(gallons_gas)
***illustrating how ‘for’ loop works.
This program needs to work with Microsoft visual studio!

Explanation / Answer

#include<iostream>

using namespace std;

int main()

{

int z;

cout<<"Enter the number of data points: "; cin>>z;

double n[z],o[z],g[z],a[z];

for(int i=0;i<z;i++)

{

cout<<"Enter New odometer reading : ";

cin>>n[i];

cout<<"Enter Old odometer reading : ";

cin>>o[i];

cout<<"Enter the amount of gas used : ";

cin>>g[i];

a[i]=((n[i]-o[i])/g[i]);

}

double ans=0;

for(int i=0;i<z;i++)

{

ans=ans+a[i];

}

ans=ans/z;

cout<<"Average Milage is : "<<ans;

system("pause");

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote