Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace Római
  12. {
  13. public partial class Form1 : Form
  14. {
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19.  
  20. int szam;
  21. string romai;
  22.  
  23. private void btRomai_Click(object sender, EventArgs e)
  24. {
  25. romai = null;
  26. tbRomai.Clear();
  27.  
  28. szam = Convert.ToInt32(tbSzam.Text);
  29.  
  30. do
  31. {
  32. if (szam >= 1000)
  33. {
  34. romai += 'M';
  35. szam -= 1000;
  36. }
  37.  
  38. else if (szam >= 900)
  39. {
  40. romai += "CM";
  41. szam -= 900;
  42. }
  43.  
  44. else if (szam >= 500)
  45. {
  46. romai += 'D';
  47. szam -= 500;
  48. }
  49.  
  50. else if (szam >= 400)
  51. {
  52. romai += "CD";
  53. szam -= 400;
  54. }
  55.  
  56. else if (szam >= 100)
  57. {
  58. romai += 'C';
  59. szam -= 100;
  60. }
  61.  
  62. else if (szam >= 90)
  63. {
  64. romai += "XC";
  65. szam -= 90;
  66. }
  67.  
  68. else if (szam >= 50)
  69. {
  70. romai += 'L';
  71. szam -= 50;
  72. }
  73.  
  74. else if (szam >= 40)
  75. {
  76. romai += "XL";
  77. szam -= 40;
  78. }
  79.  
  80. else if (szam >= 10)
  81. {
  82. romai += 'X';
  83. szam -= 10;
  84. }
  85.  
  86. else if (szam >= 9)
  87. {
  88. romai += "IX";
  89. szam -= 9;
  90. }
  91.  
  92. else if (szam >= 5)
  93. {
  94. romai += 'V';
  95. szam -= 5;
  96. }
  97.  
  98. else if (szam >= 4)
  99. {
  100. romai += "IV";
  101. szam -= 4;
  102. }
  103.  
  104. else if (szam >= 1)
  105. {
  106. romai += 'I';
  107. szam -= 1;
  108. }
  109.  
  110. } while (szam != 0);
  111.  
  112. tbRomai.Text = romai;
  113.  
  114. }
  115. }
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement