Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.55 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 Trabalho_Calculadora
  12. {
  13. public partial class Form1 : Form
  14. {
  15. double v1, v2, total;
  16. char operacao;
  17. public Form1()
  18. {
  19. InitializeComponent();
  20. }
  21.  
  22. private void btn1_Click(object sender, EventArgs e)
  23. {
  24. txtvisor.Text = txtvisor.Text + 1;
  25. }
  26.  
  27. private void btn2_Click(object sender, EventArgs e)
  28. {
  29. txtvisor.Text = txtvisor.Text + 2;
  30. }
  31.  
  32. private void btn3_Click(object sender, EventArgs e)
  33. {
  34. txtvisor.Text = txtvisor.Text + 3;
  35. }
  36.  
  37. private void btn4_Click(object sender, EventArgs e)
  38. {
  39. txtvisor.Text = txtvisor.Text + 4;
  40. }
  41.  
  42. private void btn5_Click(object sender, EventArgs e)
  43. {
  44. txtvisor.Text = txtvisor.Text + 5;
  45. }
  46.  
  47. private void btn6_Click(object sender, EventArgs e)
  48. {
  49. txtvisor.Text = txtvisor.Text + 6;
  50. }
  51.  
  52. private void btn7_Click(object sender, EventArgs e)
  53. {
  54. txtvisor.Text = txtvisor.Text + 7;
  55. }
  56.  
  57. private void btn8_Click(object sender, EventArgs e)
  58. {
  59. txtvisor.Text = txtvisor.Text + 8;
  60. }
  61.  
  62. private void btn9_Click(object sender, EventArgs e)
  63. {
  64. txtvisor.Text = txtvisor.Text + 9;
  65. }
  66.  
  67. private void btn0_Click(object sender, EventArgs e)
  68. {
  69. txtvisor.Text = txtvisor.Text + 0;
  70. }
  71.  
  72. private void btnmais_Click(object sender, EventArgs e)
  73. {
  74. v1 = Convert.ToDouble(txtvisor.Text);
  75. txtvisor.Clear();
  76. operacao = '+';
  77. }
  78.  
  79. private void btnigual_Click(object sender, EventArgs e)
  80. {
  81. v2 = Convert.ToDouble(txtvisor.Text);
  82. if(operacao == '+')
  83. {
  84. total = v1 + v2;
  85. txtvisor.Text = Convert.ToString(total);
  86. }
  87.  
  88.  
  89. if (operacao == '-')
  90. {
  91. total = v1 - v2;
  92. txtvisor.Text = Convert.ToString(total);
  93. }
  94.  
  95. if (operacao == '*')
  96. {
  97. total = v1 * v2;
  98. txtvisor.Text = Convert.ToString(total);
  99. }
  100.  
  101. if (operacao == '/')
  102. {
  103. total = v1 / v2;
  104. txtvisor.Text = Convert.ToString(total);
  105. }
  106.  
  107. total = Math.Pow(v1, v2);
  108. txtvisor.Text = Convert.ToString(total);
  109.  
  110. if (operacao == '%')
  111. {
  112.  
  113. total = v1 * v2 / 100;
  114. txtvisor.Text = Convert.ToString(total);
  115.  
  116. }
  117.  
  118.  
  119. }
  120.  
  121. private void btnmenos_Click(object sender, EventArgs e)
  122. {
  123. v1 = Convert.ToDouble(txtvisor.Text);
  124. txtvisor.Clear();
  125. operacao = '-';
  126. }
  127.  
  128. private void btnvezes_Click(object sender, EventArgs e)
  129. {
  130. v1 = Convert.ToDouble(txtvisor.Text);
  131. txtvisor.Clear();
  132. operacao = '*';
  133. }
  134.  
  135. private void dtndividir_Click(object sender, EventArgs e)
  136. {
  137. v1 = Convert.ToDouble(txtvisor.Text);
  138. txtvisor.Clear();
  139. operacao = '/';
  140. }
  141.  
  142. private void Form1_Load(object sender, EventArgs e)
  143. {
  144.  
  145. }
  146.  
  147. private void btnlimpar_Click(object sender, EventArgs e)
  148. {
  149. txtvisor.Clear();
  150. }
  151.  
  152. private void btnraiz_Click(object sender, EventArgs e)
  153. {
  154. v1 = Convert.ToDouble(txtvisor.Text);
  155. txtvisor.Clear();
  156. total = Math.Sqrt(v1);
  157. txtvisor.Text = Convert.ToString(total);
  158. }
  159.  
  160. private void btnpotencia(object sender, EventArgs e)
  161. {
  162. v1 = Convert.ToDouble(txtvisor.Text);
  163. txtvisor.Clear();
  164. operacao = '^';
  165. }
  166.  
  167. private void btnporcentagem_Click(object sender, EventArgs e)
  168. {
  169. v1 = Convert.ToDouble(txtvisor.Text);
  170. txtvisor.Clear();
  171. operacao = '%';
  172. }
  173.  
  174. private void btncosseno_Click(object sender, EventArgs e)
  175. {
  176. v1 = Convert.ToDouble(txtvisor.Text);
  177. txtvisor.Clear();
  178. total = Math.Cos(v1);
  179. txtvisor.Text = Convert.ToString(total);
  180. }
  181.  
  182. private void button2_Click(object sender, EventArgs e)
  183. {
  184.  
  185. }
  186.  
  187. private void seno_Click(object sender, EventArgs e)
  188. {
  189. v1 = Convert.ToDouble(txtvisor.Text);
  190. txtvisor.Clear();
  191. total = Math.Sin(v1);
  192. txtvisor.Text = Convert.ToString(total);
  193. }
  194.  
  195. private void tangente_Click(object sender, EventArgs e)
  196. {
  197. v1 = Convert.ToDouble(txtvisor.Text);
  198. txtvisor.Clear();
  199. total = Math.Tan(v1);
  200. txtvisor.Text = Convert.ToString(total);
  201. }
  202.  
  203. private void btnlog_Click(object sender, EventArgs e)
  204. {
  205. v1 = Convert.ToDouble(txtvisor.Text);
  206. txtvisor.Clear();
  207. total = Math.Log10(v1);
  208. txtvisor.Text = Convert.ToString(total);
  209. }
  210. }
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement