Advertisement
jadestorm23

Untitled

May 8th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. //Hunter Basinger Roman Numerals 5/5/17
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <windows.h>
  5. using namespace std;
  6. #include <time.h>
  7. #include <iomanip>
  8. void setFontSize(int FontSize)
  9. {
  10. CONSOLE_FONT_INFOEX info = {0};
  11.  
  12. info.cbSize = sizeof(info);
  13.  
  14. info.dwFontSize.Y = FontSize;
  15. info.FontWeight = FW_NORMAL;
  16.  
  17. wcscpy(info.FaceName,L"Lucida Console");
  18.  
  19. SetCurrentConsoleFontEx(GetStdHandle(STD_OUTPUT_HANDLE), NULL, &info);
  20. }
  21.  
  22. void SetColor(int ForgC)
  23. {
  24. WORD wColor;
  25. HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
  26. CONSOLE_SCREEN_BUFFER_INFO csbi;
  27. // we use csbi for the wattributes word.
  28.  
  29. if(GetConsoleScreenBufferInfo(hStdOut, &csbi))
  30. {
  31. //mask out al but the background attribute, and add in the forground color
  32. wColor=(csbi.wAttributes & 0xF0) + (ForgC & 0x0F);
  33. SetConsoleTextAttribute(hStdOut, wColor);
  34. }return;
  35.  
  36. }
  37. int RomanNumber(int Start, int End)
  38. {
  39. for(; Start <= End; Start++)
  40. {
  41. if(Start == 1)
  42. {
  43. SetColor(12);
  44. cout<<"1. I" << endl;
  45. }
  46.  
  47. else if(Start == 2)
  48. {
  49. SetColor(4);
  50. cout<<"2. II" << endl;
  51. }
  52.  
  53. else if(Start == 3)
  54. {
  55. SetColor(14);
  56. cout<<"3. III" << endl;
  57. }
  58.  
  59. else if(Start == 4)
  60. {
  61. SetColor(10);
  62. cout<<"4. IV" << endl;
  63. }
  64.  
  65. else if(Start == 5)
  66. {
  67. SetColor(3);
  68. cout<<"5. V" << endl;
  69. }
  70. else if(Start == 6)
  71. {
  72. SetColor(1);
  73. cout<<"6. VI" << endl;
  74. }
  75.  
  76. else if(Start == 7)
  77. {
  78. SetColor(5);
  79. cout<<"7. VII" << endl;
  80. }
  81.  
  82. else if(Start == 8)
  83. {
  84. SetColor(7);
  85. cout<<"8. VIII" << endl;
  86. }
  87.  
  88. else if(Start == 9)
  89. {
  90. SetColor(13);
  91. cout<<"9. IX" << endl;
  92. }
  93.  
  94. else
  95. {
  96. SetColor(15);
  97. cout<<"10. X" << endl;
  98. }
  99. }
  100. }
  101.  
  102. int main(int argc, char** argv)
  103. {
  104. setFontSize(20);
  105. int i;
  106. int x;
  107. cout<<"\t ____________" <<endl;
  108. cout<<"\t| |" << endl;
  109. cout<<"\t|ROMAN NUMBER| " << endl;
  110. cout<<"\t|____________|"<< endl;
  111. cout<< endl;
  112. cout<<"During this program it will display the number and roman numberal equivalent." << endl;
  113. cout<<"This program will only display 1 - 10." << endl;
  114. cout<< endl;
  115.  
  116. cout<<"Please choose the number you wish to start with: ";
  117. cin >> i;
  118.  
  119. cout<< endl;
  120.  
  121. if(i > 10 || i <= 0)
  122. {
  123. cout<<"Error! Error! Your number can't go higher than 10 or be lower than 1! Please re-enter." << endl;
  124.  
  125. cout<<"Please chose the number you wish to start with: ";
  126. cin >> i;
  127. cout<< endl;
  128.  
  129. }
  130.  
  131. cout<<"Please choose the number you wish the end with: ";
  132. cin >> x;
  133.  
  134. cout<< endl;
  135.  
  136. SetColor(10);
  137.  
  138. if(x > 10)
  139. {
  140. cout<<"Error! Error! Your number can't be higher than 10! Please re-enter." << endl;
  141.  
  142. cout<<"Please choose the number you wish the end with: ";
  143. cin >> x;
  144. cout<< endl;
  145. }
  146. cout << endl;
  147. RomanNumber(i, x);
  148. SetColor(10);
  149. return 0;
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement