Please input a number x, if the number is even, then shows that \" The number x
ID: 3632796 • Letter: P
Question
Please input a number x, if the number is even, then shows that " The number x is even number“; if the number is odd, then shows " The number x is odd numberIf you input a number it is not integer, and please shows "Please input the right format: (It must be a integer type)" Hint: Use "try" and "catch"
If you input "1000", and then stop this program (Hint: Use “ while”)
--------------------------------------------------------------
Output:
Please input a number:(Stop this programming if you input 1000)
5
The number 5 is odd number
Please input a number:(Stop this programming if you input 1000)
6
The number 6 is even number
Please input a number:(Stop this programming if you input 1000)
5.5
Please input the right format: (It must be a integer type)
Please input a number:(Stop this program if you input 1000)
1000
I won't forget to rate LifeSaver for best answer! Thanks!
Explanation / Answer
Note: Please first check exception handling is working on your system or not. #include #include int main() {int no;float f; coutf; no=f; while(no!=1000) { try { if(f==no) {if(no%2==0)coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.