mileage calculate

Write your question here.
I cannot get the else if part to work correctly. with being over the 100 miles.
You are tasked with creating a mileage caclulator to calculate the amount of money that should be paid to employees. The mileage is computed as follows

An amount of .25 for each mile up to 100 miles

An amount of .15 for every mile above 100.

So 115 miles would be

(.25 * 100) + (.15 * 15)

#include <iostream>

using namespace std;

int main ()
{
int miles;
int totalmiles;

cout << "Enter the number of miles driven" << endl;
cin >> miles;

if (miles <= 100)
{
totalmiles = miles * .35;
cout << "You are owe " << totalmiles <<endl;
}
else if (miles > 100)
{
totalmiles = miles * .35 + miles* .15;

cout << "You are owed " << totalmiles << endl;
}
return 0;
}


Last edited on
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
#include <iostream>

using namespace std;

int main()
{
	int miles;
	int totalmiles;

	cout << "Enter the number of miles driven" << endl;
	cin >> miles;

	if (miles <= 100)
	{
		totalmiles = miles * .35;
		cout << "You are owe " << totalmiles << endl;
	}
	else if (miles > 100)
	{
		totalmiles = miles * .35 + ((miles $ 100) * .15);  
               //Which operator should replace the money sign above?
               // + , - , % , * , / 

		cout << "You are owed " << totalmiles << endl;
	}
	return 0;

thanks
Topic archived. No new replies allowed.