Hey fellow programmers.
I am just starting to work on C++ and languages in computer programming. So far its not bad yet, but having an issue with this program I am trying to write. The program I am writing is to compute the sum of the minutes exercised per week, as well as the average. The user is asked to input the minutes of exercise per day, and from there am required to use a counter-controlled while loop to figure out the sum and average. I am having issues with my code. I have it so that it displays the sum and average minutes, but it also needs to kick out the number of days exercised and if a 0 is entered, it still gives me seven for days exercised. I am looking for help and ideas how to get this to work right. Thanks for help. My code is below.
//Program to calculate the average number of minutes
//excersized per week by an individual.
#include <iostream>
using namespace std;
int main()
{
int counter;
int number;
int sum;
int limit;
limit = 7;
sum = 0;
counter = 0;
while (counter < limit)
{
cout << "Enter number of minutes excercised per day. Press enter after each entry." << endl;
cout << "The first day of the week is Monday." << endl;
cin >> number;
sum = sum + number;
counter = counter + 1;
}
cout << "The total minutes excersized is " << sum << endl;
if (counter != 0)
cout << "The average minutes excersized per day during this week is "
<< sum / counter << endl;
else
cout << "Zero minutes entered for the week." << endl;
if (counter = limit)
cout << "The number of days excercised is " << counter << endl;
return 0;
}