1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
|
#include <cstdlib>
#include <iostream>
using namespace std;
//Prototypes
int getDays(int);
void getCal(int*,int);
float calcSum(float,int*,int);
float calcAvg(float,int);
void sortRay(int*,int*,int);
int main(int argc, char *argv[])
{
int days;
int *calorie;
int *day;
float sum = 0;
float average = 0;
days = getDays(days);
day = new int[days];
calorie = new int[days];
getCal(calorie,days);
sum = calcSum(sum,calorie,days);
average = calcAvg(sum,days);
cout << days << endl;
cout << sum << endl;
cout << showpoint << average << endl;
for (int i = 0; i < days; i++)
{
cout << calorie[i] << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
//******************************************************************************
int getDays(int days)
{
cout << "Please type how many days to track for the month 1-31" << endl;
cin >> days;
while (days <= 0 || days > 31)
{
cout << "please provide a valide amount" << endl;
cin >> days;
}
return days;
}
//******************************************************************************
void getCal(int* calorie,int days)
{
for (int i = 0; i < days; i++)
{
cout << " How many calories where taken? " << endl;
cin >> calorie[i];
}
}
//******************************************************************************
float calcSum(float sum, int* calorie,int days)
{
int average;
for (int i = 0; i < days; i++)
{
sum+=calorie[i];
}
return sum;
}
//******************************************************************************
float calcAvg(float sum,int days)
{
float average = 0;
average = (float)sum / (float)days;
return average;
}
//******************************************************************************
void sortRay(int* day, int* calorie,int days)
{
}
|