Made a program that prints out a string, depending on the amount you input in. For some reason, only the default case works. Not sure how to make it give me my exact result

You set maxScore to 100 and any of your swithc cases it is executed. Change maxScore to 95 and re-run…

It only gives me the first case. I made the declaration of the maxScore package scope also. No changes

It has nothing to do with the scope of the variable. It has to do with the value you have assigned. Try changing its value to 95 so you can see that if the first clause of your swicth is satisfied

You do the same error with every boundary. 100 is not less than 100, 90 is neither less than nor greater than 90, etc.

1 Like

Yup. I should remove that maxGrade and use the parameter I passed in

Thats not what I’m talking about…

Have you tried entering 90 or 80?
I’m meant to pass the number through the command line. So no need to declare it manually.
This works perfectly on my IDE, on the playground, doesn’t(guess that happens pretty often)

Well, the playground doesn’t allow interaction, you can’t neither specify arguments, nor can you enter something.

Just try to call your function with some sample values.

10, 65, 75, 85, 95, 70, 80, 90, 100

1 Like

agreed with @Nobbz, the reason it kept failing is because it does not have any input value, thus it always hit the default cases.

I modified your source code a bit using integer slices ( This way, you can test it on playground.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.