Question
Need help with this program ASAP These are some simple exercise for you to practice conditional statements including if, if-else, if else-if and switch case.
Need help with this program ASAP
These are some simple exercise for you to practice conditional statements including if, if-else, if else-if and switch case. You can solve a problem in multiple ways. Try writing different programs for solving the problems and think which one is better and why.
1. Find and print the smallest and the largest of 3 numbers (You can ask the user to enter the 3 numbers from keyboard, if you are familiar with that concept otherwise you can simply initialize the 3 numbers.
2. Assign and print the grade based on the score of a student according to the following conditions (use if, if-else, if else id...whatever works best for you-remember there are multiple ways to do it and achieve what you want.)
Score | Grade |
90-99 | A |
80-89 | B |
70-79 | C |
60-69 | D |
<60 | F |
3. Use a switch-case to implement the same program as discussed in 2 above. (Note: you can not assign range of numbers in a case, you can only use a single number....and you would also not want to write 100 cases for each score....not that it is incorrect but just doesn't look like the right way to approach the problem. So you have to handle this a little smartly by representing the whole range by a single number and use that number in the case statement. Hint: divide the score by 10 and use the answer in your switch statement instead of the original score and similarly change the case statement values as well.)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started