Question: Write a program that asks the user to enter a menu of numbers: ( for example: 100, 150, 170, 200). Based on number entered, output
Write a program that asks the user to enter a menu of numbers: ( for example: 100, 150, 170, 200). Based on number entered, output the binary equivalent. Implement using an if else chain. Repeat the process using a do-while loop
here's the code that i did !
| double selection; | |
| 11 | - cout << "Enter a Hexadecimal number; (15 , 20 , 25 , 30 , 35 )"; |
| 12 | - >>endl ; |
| 13 | - cin >> selection; |
| 14 | - |
| 15 | - |
| 16 | - if (selection == 15) |
| 17 | - cout << "Binary # is: 01111" << endl; |
| 18 | - else if (selection == 20) |
| 19 | - cout << "Binary # is: 010100" << endl; |
| 20 | - else if (selection == 25) |
| 21 | - cout << "Binary # is: 011001" << endl; |
| 22 | - else if (selection == 30) |
| 23 | - cout << "Binary # is: 011110" << endl; |
| 24 | - else if (selection == 35) |
| 25 | - cout << "Binary # is: 010011" << endl; |
| 26 | - else |
| 27 | - cout << " invalid selection" << endl; |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
