Prompt the user to select (from a menu) the data type of a series of values which the user will eventually enter. Then, as we did in lab 8, use a switch statement with the enumerators of an enumerated type as case labels to dynamically define an array of this data type whose size is to be entered by the user. From within the appropriate switch block, call a function to initialize the array. (NOTE: This function should use a template to handle any of the data types that the user could select. The function does not have to perform the dynamic memory allocation; it only has to initialize the array.) Your enumerators should include at least the following data types: INTEGER, FLOAT, and DOUBLE. Then, using another menu and switch statement, prompt the user to select which of the following means he/she wishes to have be calculated from the values entered above: arithmetic, geometric, and harmonic. As before, the switch statement should use enumerators (ARITHMETIC, GEOMETRIC, HARMONIC) as its case labels. Each case block should call the appropriate function to calculate the appropriate mean. ALL THREE OF THESE MEANS FUNCTIONS, JUST LIKE THE ARRAY INITIALIZATION FUNCTION, SHOULD BE TEMPLATED TO ALLOW FOR THE ORIGINAL DATA TYPE. Keep in mind that only positive values are valid for the geometric mean, while only non-zero values are valid for the harmonic mean. For the record, the arithmetic equals the sum of all n values divided by n; the geometric mean equals the nth. root of the product of all n values; and the harmonic mean equals n divided by the sum of the reciprocals of all n values.
LOL, NO i am not going to say "hey someone in this forum do this for me" of course not. I am just confused on the requirement. I am in a situation where (i don't even know what he want how can i code it) Is it because English isn't my second languages or what but i just don't get what he want so let's break it down correct me if i am wrong. I'll break it down line by line.
1)Prompt the user to select (from a menu) the data type of a series of values which the user will eventually enter.
Something like this?
1 2 3 4 5 6 7 8 9
|
void drawmenu(void)
{
cout<<endl<<"\t1 - interger"<<endl;
cout<<"\t2 - float" <<endl;
cout<<"\t3 - double"<<endl;
cout<<"\t4 - end this program"<<endl;
}
then later use the switch statement bla bla bla.
|
2)Then, as we did in lab 8, use a switch statement with the enumerators of an enumerated type as case labels to dynamically define an array of this data type whose size is to be entered by the user.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
probably something like this?
enum IFDCAL {INTEGER = 1, FLOAT, DOUBLE};
IFDCAL myOps = INTEGER;
myOps = IFDCAL(choice);
switch(myOps)
{
case INTEGER:
//blablabla
break;
case FLOAT:
//blablabla
break;
case DOUBLE:
//blablabla
break;
default:
cout<<"thank you for using !"<<endl;
}
}
|
3) From within the appropriate switch block, call a function to initialize the array. (NOTE: This function should use a template to handle any of the data types that the user could select. The function does not have to perform the dynamic memory allocation; it only has to initialize the array.)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
something like this?
myOps = IFDCAL(choice);
switch(myOps)
{
case INTEGER:
cout<<funnyfunc(inum1, inum2, inum3)<<endl;
break;
case FLOAT:
cout<<funnyfunc(fnum1, fnum2, fnum3)<<endl;
break;
case DOUBLE:
cout<<funnyfunc(dnum1, dnum2, dnum3)<<endl;
break;
default:
cout<<"thank you for using !"<<endl;
}
}
|
4)Your enumerators should include at least the following data types: INTEGER, FLOAT, and DOUBLE.
That's just naming the emulator.
5)Then, using another menu and switch statement, prompt the user to select which of the following means he/she wishes to have be calculated from the values entered above: arithmetic, geometric, and harmonic.
This is the part i don't get it what is arithemtic geometric and harmonic implies? i know what are those 3 terms in math but anyone give me an example?