0

How to program if statement when the input asking is 500up and 700below(numbers) w/out boundary.

I can make an imaginary boundary (600) but is there a better way to code than that?

16th Mar 2021, 5:13 AM
Jessica Zarate
Jessica Zarate - avatar
7 Réponses
+ 1
Use switch statement or if , else if , else statement
16th Mar 2021, 5:19 AM
Ayush Kumar
Ayush Kumar - avatar
+ 1
If I got your point , you have to add second condition to both if and else if. if(num>=500 && num<600) And something similar in else if
16th Mar 2021, 5:32 AM
Michal Doruch
0
But each has its own value. Input 500up Output Math Input 700below Output Social Science
16th Mar 2021, 5:18 AM
Jessica Zarate
Jessica Zarate - avatar
0
So your input must be between 500 and 700? It would be easier to understand your problem when we could see your code
16th Mar 2021, 5:28 AM
Michal Doruch
0
I was tasked to do if, else if, else statement. Right now my code looks like this: if (num>=500){ cout<<"Math"; } else if (num<=700) { cout<<"Social Science"; } ........ so when I input 699 the output is always Math
16th Mar 2021, 5:29 AM
Jessica Zarate
Jessica Zarate - avatar
0
It's frustrating when instructions are unclear/vague
16th Mar 2021, 5:32 AM
Jessica Zarate
Jessica Zarate - avatar
0
I could do that and make a boundary (600) but i was hoping there is an alternative but i guess its the only option I have. Thank you for helping me. I'll just stick to 600 as a boundary
16th Mar 2021, 5:36 AM
Jessica Zarate
Jessica Zarate - avatar