help with the math in my C++ program

Hi, i am wrighting a program that calcultes gas milage based on how much the driver uses the city/highway. here is what i have so far :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>

using namespace std;

int main(){
double tankSize, city, highway;
int cost;
int percent;

cout << "Enter the size of the gas tank of the car in gallons: ";
cin >> tankSize;

cout <<"Enter the MPG you get in the city: ";
cin >> city;

cout <<"Enter the MPG you get in the highway: "; 
cin >> highway;	

cout << "What percentage do you travel on the highway? ";
cin >> percent;





return 0;
}


i need to determine the amount of miles that can be traveled for a single tank of gas.
closed account (D80DSL3A)
Look up "interpolation" for the method here.

I'll use a double for percent instead of an int.
Assuming percent is entered as a value between 0 and 100 then:
actualMPG = highway*percent/100.0 + city*(1 - percent/100.0);
Topic archived. No new replies allowed.