This isn't essential, but I'd recommend using "double" instead of "float" - the reason being that float has very low precision... you may end up with your results being incorrectly rounded... double means "double precision" - which is much more accurate
//getdata gets the days absent by using call by reference
//nothing is returned, nor do hyou need to give it values.
void getdata (float *days out, float *total, float *average, char name[40])
"days out" is not a valid variable name, you can't use spaces. call it something like DaysOut or days_out instead.{
cout << "enter name ";
cin >> name;
cout << "enter days absent ";
cin >> days absent;
again - "days absent" is an error - there's a space in it. Also, you didn't call it "days absent", you called it "days out" if (argc > 1)
{
cout << "Total:\n";
for (int count = 1; count < argc; count++)
cout << argv[count] << endl;
} I don't know why you are doing this, but OK.float calculattoal(float(total)
Take away the second curvy bracket ( - it should read (float total)float calcaverage(float total)
{
float average
average=total/employees;
return(total);
}
Are you sure you want to return total? I think you want to return average.void outputvalues (char name[], float total, average)
{
cout <
instead of using char* and char[] for strings of text, use the C++ 'string' type - you might find it makes your life MUCH easier. (For a start - you would not have to specify the length with a C++ string, that happens automatically)int main()
{
char name [40]
float days, total, average;
getdata(&days, &total, &average);
for (int count = 1; count < argc; count++)
cout << argv[count] << endl;
total=calculatetotal(days);
average=calcaverage(total);
putputvalues(name, days, total, average);
system("pause");
return 0;
}
I have to put in two input validations. I don't need you to write the program for me. I just need some ideas on how to write it.
input validations for what exactly? what criteria are you comparing your input with?
overall, the code you pasted has quite alot of typing errors and 'bad' variable names - fix those first and make it compilable before you go any further.
Also, your "getdata" function accepts pointers and passes by address - This is OK, but you should know what you are doing with pointers before doing this (And looking at your function, you are not treating them like pointers). A much better way is to use references.
So, This....
void getdata (float *days out, float *total, float *average, char name[40])
can change to
void getdata (float &days_out, float &total, float &average, char name[40])
and when you call getdata() from main, you do not need to add the ampersand '&' for the values you send.