Code:
#include <stdio.h>
int mainPage (int First, int Second, int Third);
void inputDays (double *mile, double *calories, double weight);
int main (void)
{
int menuChoice;
double weight;
char initials , initials2 , initials3;
char cr;
double mile1, cal1;
double mile2, mile3 , mile4, mile5, mile6, mile7;
double cal2, cal3, cal4, cal5, cal6, cal7;
int first, second, third;
first = 1;
second = 0;
third = 0;
do
{
menuChoice = mainPage (first, second, third);
printf ("menuChoice %d\n", menuChoice);
if (menuChoice == 2)
{
first = 0;
second = 1;
third = 0;
printf ("Enter initials \n");
scanf ("%c%c%c%c", &initials, &initials2, &initials3, &cr);
printf ("Enter weight \n");
scanf ("%lf", &weight);
}
if (menuChoice ==3)
{
printf ("Enter initials \n");
scanf ("%c%c%c%c", &initials, &initials2, &initials3, &cr);
printf ("Enter weight \n");
scanf ("%lf", &weight);
}
if (menuChoice ==4)
{
first = 1;
second = 0;
third = 0;
inputDays (&mile1, &cal1, weight);
inputDays (&mile2, &cal2, weight);
inputDays (&mile3, &cal3, weight);
inputDays (&mile4, &cal4, weight);
inputDays (&mile5, &cal5, weight);
inputDays (&mile6, &cal6, weight);
inputDays (&mile7, &cal7, weight);
}
} while (menuChoice != 1);
return (0);
}
void inputDays (double *mile, double *calories, double weight)
{
double milesPerHour;
double Mets;
double minutes;
double steps;
double kg;
printf("Enter distance in steps:");
scanf( "%lf", &steps);
printf ("Enter minutes walked:");
scanf("%lf", &minutes);
kg = weight * 2.2;
milesPerHour = (steps/60) / 60;
*mile = steps /2000;
if (milesPerHour < 3)
{
Mets = 3;
}
if (milesPerHour >3 || milesPerHour <= 4.5)
{
Mets = 6;
}
if (milesPerHour > 4.5)
{
Mets = 7;
}
*calories = minutes * ( ( Mets * 3.5 * kg) /200);
}
int mainPage (int First, int Second, int Third)
{
int option;
int min , max;
min = 1;
do
{
printf ("1 - quit \n");
if (First ==1)
{
printf("2 - Create \n");
max = 2;
}
if (Second ==1 || Third ==1 )
{
printf ("3 -Edit\n");
printf ("4 - Start recording \n");
max =4;
}
if (Third ==1)
{
printf("5 - Reports \n");
max = 5;
}
scanf ("%d", &option);
} while ( option < min || option > max);
return (option);
}