IF greater than this BUT less than that?!

How do i do this function so IF the totals are > (larger amounts) than the rest but < (less) than the recmax (recommended journey cost) ? tried everything :(

1
2
3
4
5
6
7
8
9
10
11
12
13
  
	if (totalwagemonarch > totalwageprincess || totalwageempire || totalwagecrown || totalwagebootle) && (< recmax)
	{
	cout << "Monarch is the highest crew cost below the recommended max" << endl;
	}
	else if (totalwageprincess > totalwagemonarch || totalwageempire || totalwagecrown || totalwagebootle < recmax)
	{
	cout << "Princess is the highest crew cost below the recommended max" << endl;
	}
	else if (totalwageempire > totalwagemonarch || totalwageprincess || totalwagecrown || totalwagebootle < recmax)
	{
	cout << "Empire is the highest crew cost below the recommended max" << endl;
	}
Do the following lines fit your intention?

1
2
3
4
5
6
if (((totalwagemonarch > totalwageprincess) ||
     (totalwagemonarch > totalwageempire)   ||
     (totalwagemonarch > totalwagecrown)    ||
     (totalwagemonarch > totalwagebootle))   &&
    (totalwagemonarch < recmax))
// and so on 
no, that pattern does not exist in C/C++ yet. You have to place the conditions as
[expr] || [expr] || [expr]
where [expr] is A [op] B

so in your case
1
2
3
4
5
if ( ( (totalwagemonarch > totalwageprincess) ||
      (totalwagemonarch > totalwageempire) || 
...
   ) && (totalwagemonarch < recmax) ) { 
      cout << ...


Regards,
Dean
I'm not sure if that's your problem, but as I understand you have a value "x". If "x" is >(greater) "a" &&(AND) "x" is <(less) than "b" you want to cout.

So: if(totals > largeramounts && totals < recmax)
thanks for the help guys will let you know if any of them work!
right guys! i manalged to do the top solution, it was error free however whatever recmax i put in the first expression happens all the time it says monarch is the highest below the reocommended max even when it isnt
Topic archived. No new replies allowed.