fork download
  1. //George Molinero csc5 chapter 4, P. 220, #2
  2. //
  3. /*******************************************************************************
  4.  *
  5.  * Display Roman Numeral
  6.  * _____________________________________________________________________________
  7.  * This program Displays the Roman Numeral of the Numbers 1-10.
  8.  * _____________________________________________________________________________
  9.  * INPUT
  10.  * num : Number inputed
  11.  *
  12.  * OUTPUT
  13.  * Roman Numeral Displayed
  14.  ******************************************************************************/
  15. #include <iostream>
  16. using namespace std;
  17. int main ()
  18. {
  19. int num;
  20. cout << "Enter a number within the range of 1 through 10: ";
  21. cin >> num;
  22. cout << endl;
  23. if (num >= 1 && num <= 10)
  24. {
  25. switch(num)
  26. {
  27. case 1: cout << "The Roman numeral version of " << num << " is I.\n";
  28. break;
  29. case 2: cout << "The Roman numeral version of " << num << " is II.\n";
  30. break;
  31. case 3: cout << "The Roman numeral version of " << num << " is III.\n";
  32. break;
  33. case 4: cout << "The Roman numeral version of " << num << " is IV.\n";
  34. break;
  35. case 5: cout << "The Roman numeral version of " << num << " is V.\n";
  36. break;
  37. case 6: cout << "The Roman numeral version of " << num << " is VI.\n";
  38. break;
  39. case 7: cout << "The Roman numeral version of " << num << " is VII.\n";
  40. break;
  41. case 8: cout << "The Roman numeral version of " << num << " is VIII.\n";
  42. break;
  43. case 9: cout << "The Roman numeral version of " << num << " is IX.\n";
  44. break;
  45. case 10: cout << "The Roman numeral version of " << num << " is X.\n";
  46. break;
  47. }
  48. }
  49. else
  50. cout << "invalid number was entered";
  51. return 0;
  52. }
Success #stdin #stdout 0.01s 5276KB
stdin
4
stdout
Enter a number within the range of 1 through 10: 
The Roman numeral version of 4 is IV.