fork download
  1. //Cecilia Rangel CSC5 Chapter 4, P. 220, #2
  2. //
  3. /**************************************************************
  4.  *
  5.  * TRANSLATE ROMAN NUMERAL
  6.  * ____________________________________________________________
  7.  * This program computes which number is what roman numeral
  8.  *
  9.  * This program will utilize the following relational operators:
  10.  * >(greater than), <(less than), and ==(equal to)
  11.  *___________________________________________________________
  12.  * INPUT
  13.  * number : first user input to translate
  14.  *
  15.  * OUTPUT
  16.  * roman Numeral : roman numeral equivalent
  17.  *
  18.  **************************************************************/
  19. #include <iostream>
  20. #include <iomanip>
  21. using namespace std;
  22.  
  23. int main() {
  24. int decimal; // INPUT - decimal value to translate
  25. string romanNumeral; //OUTPUT - roman numeral equivalent of deicmal value
  26.  
  27. // VARIABLE INPUT
  28. do{
  29. cout << "Enter a decimal value in range [1, 10]: ";
  30. cin >> decimal;
  31. cout << endl;
  32. } while (decimal < 1 || decimal > 10);
  33.  
  34. cout << decimal << " is ";
  35. switch(decimal){
  36. case 1:
  37. cout << "I";
  38. break;
  39. case 2:
  40. cout << "II";
  41. break;
  42. case 3:
  43. cout << "III";
  44. break;
  45. case 4:
  46. cout << "IV";
  47. break;
  48. case 5:
  49. cout << "V";
  50. break;
  51. case 6:
  52. cout << "VI";
  53. break;
  54. case 7:
  55. cout << "VII";
  56. break;
  57. case 8:
  58. cout << "VIII";
  59. break;
  60. case 9:
  61. cout << "IX";
  62. break;
  63. case 10:
  64. cout << "X";
  65. break;
  66. }
  67. return 0;
  68. }
Success #stdin #stdout 0s 5316KB
stdin
5
stdout
Enter a decimal value in range [1, 10]: 
5 is V