I have this code and I am trying to make it look like this:
Code:
How many values are you going to enter (5-25)? 30
Too many values; try again.
How many values are you going to enter (5-25)? 2
Too few values; try again.
How many values are you going to enter (5-25)? 8
Please enter value 1: 12.2
Please enter value 2: 7.6
Please enter value 3: -200.3
Please enter value 4: 140.7
Please enter value 5: 890.23
Please enter value 6: 67.78
Please enter value 7: 99.9
Please enter value 8: 100.1
I can get the first part as in how many values you want to enter which i can get until I add the next part into it which is Please enter value. When I add this is a for loop it messes it up.
This is my code when I just add the first part
Code:
numEntered = 0;
cout << "How many values are you going to enter (5-25)";
cin >> numEntered;
while (numEntered < 5 || numEntered > 25 ) {
if (numEntered < 5) {
cout << "To Few values; try again" << endl;
cout << "How many values are you going to enter (5-25)";
cin >> numEntered;
}
else if (numEntered > 25) {
cout << "To many values; try again" << endl;
cout << "How many values are you going to enter (5-25)";
cin >> numEntered;
}
and this is what i get:
Code:
How many values are you going to enter (5-25)30
To many values; try again
How many values are you going to enter (5-25)2
To Few values; try again
How many values are you going to enter (5-25)8
This on top looks good but when i add the next part, it misses up:
This is my new code:
Code:
numEntered = 0;
cout << "How many values are you going to enter (5-25)";
cin >> numEntered;
while (numEntered < 5 || numEntered > 25 ) {
if (numEntered < 5) {
cout << "To Few values; try again" << endl;
cout << "How many values are you going to enter (5-25)";
cin >> numEntered;
}
else if (numEntered > 25) {
cout << "To many values; try again" << endl;
cout << "How many values are you going to enter (5-25)";
cin >> numEntered;
}
for (i=1; i <= numEntered; i++) {
cout << "Please enter value " << i << ": ";
cin >> A[i];
}
It makes it look like this:
Code:
How many values are you going to enter (5-25)30
To many values; try again
How many values are you going to enter (5-25)2
Please enter value 1: 8
Please enter value 2: 12.2
To Few values; try again
How many values are you going to enter (5-25)To Few values; try again
How many values are you going to enter (5-25)7.6
Please enter value 1: -200.3
Please enter value 2: 140.7
Please enter value 3: 890.23
Please enter value 4: 67.78
Please enter value 5: 99.9
Please enter value 6: 100.1
Please enter value 7:
Can you tell me what I am doing wrong