problem with nested conditional operators ? : problem

the integer is evenly divisible by 3,display "Woo". If the number is evenly divisible by 5, display "Hoo". If it is evenly divisible by both
3 and 5, display "WooHoo".Display "Sorry" otherwise.I need to use one statement for using cin to get the number.The other statement must take care of all cout, modulus, and code branching for 3, 5, and 3 & 5.You need to use nested conditional operators(the ? : )*/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
the 3% works and the 5% works along with the "sorry" but the 3% && 5% do not I just get "woo"


cout << "Please enter a number \n";
		cin >> num1;

        (num1 % 3 == 0) ? cout << " Woo\n" : (num1 % 5 == 0) ? cout << " Hoo\n": 
			((num1 % 3 == 0) && (num1 % 5 == 0)) ? cout << " Woo-Hoo\n":
			 cout << "Sorry\n";
		
		break;
		
		
		

	default:
		cout << "You didn't enter 1, 2 or 3" << endl << endl;
  
problem
Last edited on
IF divisible by 5
THEN
  IF divisible by 3
  THEN x
  ELSE z
ELSE
  IF divisible by 3
  THEN y
  ELSE w


IF divisible by 15
THEN x
ELSE
  IF divisible by 3
  THEN y
  ELSE
    IF divisible by 5
    THEN z
    ELSE w
Topic archived. No new replies allowed.