Trouble with array and calculation

How can the program pick the number automatically from the array after i enter an answer for it and show which number it picked for it?

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
  #define _USE_MATH_DEFINES 
#include <iostream> 
#include <iomanip>
using namespace std;


int main()
{

	double numberarray1[3] = { 0 ,1, 2};
	double numberarray2[2] = { 1, 2 };
	double numberarray3[3] = { 0 ,1, 2};
	double numberarray4[2] = { 1, 2, };
	double moneygain;

	cin >> moneygain;

	moneygain = (numberarray1 + numberarray2) / (numberarray3 + numberarray4);

		
	cout << gain << endl;
	cout << numberarray1 << endl;
	cout << numberarray2 << endl;
	cout << numberarray3 << endl;
	cout << numberarray4 << endl;



	return 0;
}




Actually ,I am just a beginner and it is my schoolwork.
I tried my best to complete the part of check the input is a valid number with do..while loop and cin.fail .
And i get stuck in the calculation.
I don't know how to make it pick the number from the array which i set to answer my input.
And i don't know how to make it show which number it picked.
Also i cant work division well.


please let me know how to do and correct it.

Many thanks!
Topic archived. No new replies allowed.