I am trying to limit my program to only accept four possible numbers, 1,2,3 and 4.
the current working code i have is
Code:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double x; //choice
double r; //radius
double a; //volume
double b; //surface area
double c; //area of a circle
double h; //height
double l; //length
double w; //width
do
{
cout<< "What shape would you like?"<<endl;
cout<< "1) Sphere"<< endl;
cout<< "2) Cone"<< endl;
cout<< "3) Rectangular Prism"<< endl;
cout<< "4) Cylinder"<< endl;
cout<< "Choice is ";
cin>>x;
}
while (x<1||x>4);//only want numbers 1, 2, 3, or 4
When i use the code
Code:
while (x<1||1<x<2||2<x<3||3<x<4||x>4)
it returns me to the input command every time even if i input 1,2,3 or 4
any help is useful
thx