Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You recently noticed that your clothes are tight and have decided to go on a cal

ID: 3574503 • Letter: Y

Question

You recently noticed that your clothes are tight and have decided to go on a calorie restrictive diet for the next 10 weeks. You want to build a program to help you store and evaluate your daily calorie counts. - In main, create a 2 dimension array of integers named calories that can hold 10 weeks worth of daily calorie counts. Also, in main, create looping code that asks a user to enter daily calorie counts in the form "Enter calories for week and day :" for example: the very first message to the user will be: Enter calories for week 1 day 1: and the last message will be: Enter calories for week 10 day 7: Create a void function called 'diet' which accepts ..a 2 - d array of integers of 10 rows and 7 columns. The function should read the weeks individually and print out the average calories for the week. After all weeks averages have been printed, the function should display the overall average for daily calorie intake, and suggest that you should have gained/lost weight based on the formula: lossGain = ((dailyCalorieAverage - 3500 * totalday)/3000;//negative = loss - In main, print the array values as a table and use the calorie array to call the diet function.

Explanation / Answer

// C++ code
#include <iostream>
using namespace std;

void diet(int calories[][7], int row, int column)
{
int total = 0;
for (int i = 0; i < 10; ++i)
{
int sum = 0;
for (int j = 0; j < 7; ++j)
{
sum = sum + calories[i][j];
total = total + calories[i][j];
}

cout << "Average calorie for Week " << (i+1) << ": " << (double)sum/7 << endl;
}

int totalDays = 10*7;
double dailyCalorieAverage = total/(totalDays);

double lossGain = ((dailyCalorieAverage-3500)*totalDays)/3000;

if(lossGain < 0)
cout << " You should have lost weight ";
else
cout << " You should have gained weight ";


}

int main()
{
int calories[10][7];

for (int i = 0; i < 10; ++i)
{
for (int j = 0; j < 7; ++j)
{
cout << "Enter calories for week " << (i+1) << " and day " << (j+1) << ": ";
cin >> calories[i][j];
}
}

cout << " calorie table: ";
for (int i = 0; i < 10; ++i)
{
cout << "Week " << (i+1) << ": ";
for (int j = 0; j < 7; ++j)
{
cout << calories[i][j] << " ";
}
cout << endl;
}

diet(calories,10,7);

return 0;
}


/*
output:

Enter calories for week 1 and day 1: 10
Enter calories for week 1 and day 2: 22
Enter calories for week 1 and day 3: 12
Enter calories for week 1 and day 4: 11
Enter calories for week 1 and day 5: 12
Enter calories for week 1 and day 6: 12
Enter calories for week 1 and day 7: 32
Enter calories for week 2 and day 1: 12
Enter calories for week 2 and day 2: 33
Enter calories for week 2 and day 3: 43
Enter calories for week 2 and day 4: 23
Enter calories for week 2 and day 5: 44
Enter calories for week 2 and day 6: 21
Enter calories for week 2 and day 7: 12
Enter calories for week 3 and day 1: 3
Enter calories for week 3 and day 2: 44
Enter calories for week 3 and day 3: 23
Enter calories for week 3 and day 4: 23
Enter calories for week 3 and day 5: 22
Enter calories for week 3 and day 6: 12
Enter calories for week 3 and day 7: 33
Enter calories for week 4 and day 1: 44
Enter calories for week 4 and day 2: 45
Enter calories for week 4 and day 3: 64
Enter calories for week 4 and day 4: 33
Enter calories for week 4 and day 5: 22
Enter calories for week 4 and day 6: 11
Enter calories for week 4 and day 7: 9
Enter calories for week 5 and day 1: 1
Enter calories for week 5 and day 2: 12
Enter calories for week 5 and day 3: 34
Enter calories for week 5 and day 4: 56
Enter calories for week 5 and day 5: 7
Enter calories for week 5 and day 6: 6
Enter calories for week 5 and day 7: 7
Enter calories for week 6 and day 1: 8
Enter calories for week 6 and day 2: 76
Enter calories for week 6 and day 3: 55
Enter calories for week 6 and day 4: 44
Enter calories for week 6 and day 5: 646
Enter calories for week 6 and day 6: 4
Enter calories for week 6 and day 7: 34
Enter calories for week 7 and day 1: 2
Enter calories for week 7 and day 2: 3
Enter calories for week 7 and day 3: 23
Enter calories for week 7 and day 4: 21
Enter calories for week 7 and day 5: 34
Enter calories for week 7 and day 6: 22
Enter calories for week 7 and day 7: 1
Enter calories for week 8 and day 1: 12
Enter calories for week 8 and day 2: 34
Enter calories for week 8 and day 3: 32
Enter calories for week 8 and day 4: 13
Enter calories for week 8 and day 5: 1
Enter calories for week 8 and day 6: 34
Enter calories for week 8 and day 7: 5
Enter calories for week 9 and day 1: 33
Enter calories for week 9 and day 2: 11
Enter calories for week 9 and day 3: 12
Enter calories for week 9 and day 4: 34
Enter calories for week 9 and day 5: 56
Enter calories for week 9 and day 6: 67
Enter calories for week 9 and day 7: 89
Enter calories for week 10 and day 1: 76
Enter calories for week 10 and day 2: 45
Enter calories for week 10 and day 3: 3
Enter calories for week 10 and day 4: 24
Enter calories for week 10 and day 5: 24
Enter calories for week 10 and day 6: 23
Enter calories for week 10 and day 7: 22

calorie table:
Week 1: 10 22 12 11 12 12 32
Week 2: 12 33 43 23 44 21 12
Week 3: 3 44 23 23 22 12 33
Week 4: 44 45 64 33 22 11 9
Week 5: 1 12 34 56 7 6 7
Week 6: 8 76 55 44 646 4 34
Week 7: 2 3 23 21 34 22 1
Week 8: 12 34 32 13 1 34 5
Week 9: 33 11 12 34 56 67 89
Week 10: 76 45 3 24 24 23 22

Average calorie for Week 1: 15.8571
Average calorie for Week 2: 26.8571
Average calorie for Week 3: 22.8571
Average calorie for Week 4: 32.5714
Average calorie for Week 5: 17.5714
Average calorie for Week 6: 123.857
Average calorie for Week 7: 15.1429
Average calorie for Week 8: 18.7143
Average calorie for Week 9: 43.1429
Average calorie for Week 10: 31

You should have lost weight


*/

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote