hi guys can you please help i am struggling to write this program... where ever i have put //help
#include <iostream>
using namespace std;
int main()
{
float mileage, highestMileage, totalMileage;
int i = 1, day = 1;
cout << "Enter mileage for November " << i << ": ";
cin >> mileage;
totalMileage = mileage;
highestMileage = mileage;
for (int i = 1 ; i <= day; ++i) //help
{
cout << "Enter mileage for November " << i << ": ";
cin >> mileage;
if ( > highestMileage) //help
{
day = ; //help
highestMileage = mileage;
}
totalMileage = ;//help
}
cout << "Total Mileage for November was :" << totalMileage << endl;
cout << "Highest Mileage was: " << highestMileage << " on " << day << " of November " << endl;
It looks like day should be the day of the highest mileage and you want to enter the mileage for each day in November. You enter the mileage for November 1 first, so this: for (int i = 1 ; i <= day; ++i) //help should be for (int i = 2 ; i <= 30; ++i)if ( > highestMileage) //help
You want to know if the current mileage is higher than the highest mileage so far, so it should be if ( mileage> highestMileage)day = ; //help You want to set day to the current day, which is i: day = i;totalMileage = ;//help You want to sum up the mileage for each day, so that's: totalMileage += mileage; (+= adds the right side to the variable on the left side)