i wrote a code which should accept only two values, but it seems to accept any values instead. can some show me where i went wrong.
sorry about the long code, still a newbie at this.

double hr::change_r(double sr) //implementation from class section
{
   dr = sr;   
    if(sr == 17)
      return 17;
    else  
      return dr; 
}

int main()  // the main section
{
   int s
  cout<<"Enter amount: ";
  cin>>s;
   if (HR.change_r(s) == 11)
    {
          cout<<"regular\n";
    }
    if (HR.change_r(s) == 17)
    {
          cout<<"irregular\n";
    }
    if((HRoom.change_rate(season) < 150.00) &&     (HRoom.change_rate(season) > 150.00) || (HRoom.change_rate(season) < 175.00) &&(HRoom.change_rate(season) > 175.00))
    {
           cout<<"Incorrect room rate entered";
           cin>>season;
    while((HRoom.change_rate(season) < 150.00) && (HRoom.change_rate(season) > 150.00) || (HRoom.change_rate(season) < 175.00) &&(HRoom.change_rate(season) > 175.00))
     {
                cout<<"Please re-enter the room rate \n";
                cin>>season; 
      }

change_r() is pointless. All it does is return the same value that was passed in as the parameter.

i take it you are trying to see if the user entered 150 or 175 as the rate and if they do not then tell them they have a wrong entry and re ask for the room rate a simple way for this would be to do this

int rate // this can be any type
cout << "Please enter the room rate: ";
cin >> rate
if ((rate != 150) || (rate != 175)// this will make sure you only get 150 or 175
{
// loop for the right response

er, you aren't initialising 'dr'

thanks again ancient dragon and nathan oliver

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.