fork download
  1. //Max Kichuk CS1A Chapter 4, P.220, #2
  2.  
  3. /**********************************************************************
  4.  *
  5.  * ROMAN NUMERAL CONVERTER
  6.  * ____________________________________________________________________
  7.  * This program converts regular numbers into roman numerals.
  8.  * It only converts numbers between 1-10.
  9.  * ____________________________________________________________________
  10.  * INPUT
  11.  * user_number : Number being converted to a roman numeral
  12.  *
  13.  **********************************************************************/
  14. #include <iostream>
  15. using namespace std;
  16.  
  17. int main() {
  18. int user_number; // INPUT: Number being converted to a roman numeral
  19.  
  20. // Ask the user to enter a number
  21. cout << "Enter a number between 1 and 10" << endl;
  22. cout << endl;
  23. cin >> user_number;
  24.  
  25. // Check to see if the number is between 1-10
  26. if (user_number >= 1 && user_number <= 10){
  27. // Convert number to roman numerals
  28. switch(user_number){
  29. case 1: cout << "You entered the roman numeral I";
  30. break;
  31. case 2: cout << "You entered the roman numeral II";
  32. break;
  33. case 3: cout << "You entered the roman numeral III";
  34. break;
  35. case 4: cout << "You entered the roman numeral IV";
  36. break;
  37. case 5: cout << "You entered the roman numeral V";
  38. break;
  39. case 6: cout << "You entered the roman numeral VI";
  40. break;
  41. case 7: cout << "You entered the roman numeral VII";
  42. break;
  43. case 8: cout << "You entered the roman numeral VIII";
  44. break;
  45. case 9: cout << "You entered the roman numeral IX";
  46. break;
  47. case 10: cout << "You entered the roman numeral X";
  48. break;
  49. }
  50. }
  51. // Check if user entered invalid number
  52. else{
  53. cout << "You entered an invalid number" << endl;
  54. cout << "Your number must be between 1-10";
  55. }
  56. return 0;
  57. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
Enter a number between 1 and 10

You entered an invalid number
Your number must be between 1-10