Here you have made some mistakes
1) Gerenating vector instead of single random number
Here use single interger random value as
2) While loops
What is the need to use while loop, you can go with if else condition
If necessory, put break keyword in each while loop.
3) comparing single user input value x to y vector in while loop condition checking