I have an assignment where we have to input this sample code and get the following results:
----------
./lab3
Please enter the vectors here:
1 2 3 4 2 s
You are not giving even number of inputs!
./lab3
Please enter the vectors here:
1 2 3 2 4 4 s
The sample values are:
1 2 3
The frequencies are:
2 4 4
The discrete probability distribution is:
0.2 0.4 0.4
The mean is 2.2.
The variance is 0.56.
-----------
I got the part with the mean, variance , and probability distribution but i cannot split up user input into vectors for sample values and frequencies.
"1 2 3" are suppose to become sample values and "2 4 4" are suppose to become the frequencies.
------------
------------
I also wanted to know how to properly make the code so if there is an odd number of inputs the code outputs "You are not giving even number of inputs!". But if is an even number of inputs the code runs. To do this I have:
int main(int argc, char** argv){
float input = 1.0;
cout<<"Please enter vectors here:"
cin>>input;
// This states if size of vector is odd code does not run.
if (size(input % 2 != 0)){
cout<<"You are not giving even number of inputs!"
break;
}
//If size of vector is even then the code runs
else{
//rest of code
}
-------------
-------------
This is due tonight, 2/5/15 by 11:59 EST. Any help on how to properly do this is appreciated. Thank you.