Hello,
I am a beginner in the world of C++. I have been asked to perform the following task for a class that I am in. I am not looking for somone to do my work for me, but I need a little help getting started. What would be the first things that you would to set up this program. Thanks in advanced.
Travis
Problem:Write a program that calculates the average number of minutes the user exercised per day over the course of a week. You will ask the user to input the amount of exercise he or she did for each day of the week. Implement this with a count-controlled loop, in which the day of the week corresponds to the counter (assume that the first day is Monday). Note that the user will be prompted by the name of the day, not by the number; you will need a nested selection structure to implement this functionality. Output the average minutes of exercise per day in the week as well as the number of days exercised.
Start with a loop from 0 to 6 in which you display the day and get the number of minutes for that day. Each time you get the input add it to a variable.
At the end of the loop display the sum of the input values divided by 7
First, go through the problem and list all the pieces of information you need to track. This is your list of variables.
Second, break the problem down into a list of discrete task. For each task, determine the following things:
1. Which of your variables are used and/or modified by this task.
2. What input is required for this task.
3. What output is required for this task.
5. What control structures are required for this task. If this ends up being more than 2 or 3 control structures total, the task needs to be broken down into more discrete tasks.
Create your project. Go to the first task, write the code to perform that task. Repeat till all tasks are implemented.
Start using a for loop that counts from 0-6 or 1-7 or whatever and then use a switch statement to print the day of the week. Then get the input and add it to a variable. End the loop and print the results.
a quick example to start you off:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int total_minutes;
for(int i = 0; i < 7; i++)
{
cout << "How many minutes of exercise did you do on ";
switch(i)
{
case 0:
cout << "Sunday? ";
break;
/* Continue on */
}
//Get the input
}
cout << "blablabla Your results\n";
return 0;