So, 20 to 25 range is for my Tinitial value. Tinitial must be either 20, 21, 22, 23, 24 or 25. if its less than 20 i want an error message to pop up. if its greater than 25 i want an error message to pop up. If the user enters 20,21,22,23,24,or25 then i want the program to continue to the next while loop where i will have them pick between 50 and 100 for my Tside value. 4 of my variables in my long equation have parameters. Once the user picks the right number for the 4 variables. I want my program to put into the equation i wrote to solve and compute it. I have no problem with the equation. Its getting the user to pick the right numbers between the paramters for 4 of my variables , then moving on. Does that make sense ?
#include <iostream>
#include <cmath>
#include <fstream>
usingnamespace std;
int main () {
int number;
cout << "Enter a number between 20 and 25: ";
cin >> number;
while (number < 20 || number > 25)
{
cout << "Error ! Enter number again !: ";
cin >> number;
}
return 0;
}
the while loop is when it is false. I was entering <= and >= because that is what i wanted TRUE. Now it makes so much sense ! Thank you for working with me as long as you have. Now when i go to the next while loop i do the same thing ? when i entered 20 my program just stopped. Is that because I hadnt entered anything below it ?
uh oh... this is my last question. I got it to work for 3 of my loops. but on the 0.005 - 0.008 one.. it kept entering my error message non stop. do you know why ? heres my code
#include <iostream>
#include <cmath>
#include <fstream>
usingnamespace std;
int main () {
int number;
cout << "Enter a number between 20 and 25: ";
cin >> number;
while (number < 20 || number > 25)
{
cout << "Error ! Enter number again !: ";
cin >> number;
}
cout << "Enter a number between 50 and 100: ";
cin >> number;
while (number < 50 || number > 100)
{
cout << "Error ! Enter number again !: ";
cin >> number;
}
cout << "Enter a number between 0.005 and 0.008: ";
cin >> number;
while (number < 0.005 || number > 0.008)
{
cout << "Error ! Enter number again !: ";
cin >> number;
}
cout << "Enter a number between 1 and 50: ";
cin >> number;
while (number < 1 || number > 50)
{
cout << "Error ! Enter number again: !";
cin >> number;
} return 0;
}