Advertisement
Guest User

Untitled

a guest
Sep 17th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 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_ok_
  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 btnmenos_Click(object sender, EventArgs e)
  80. {
  81. v1 = Convert.ToDouble(txtvisor.Text);
  82. txtvisor.Clear();
  83. operacao = '-';
  84. }
  85.  
  86. private void btnvezes_Click(object sender, EventArgs e)
  87. {
  88. v1 = Convert.ToDouble(txtvisor.Text);
  89. txtvisor.Clear();
  90. operacao = '*';
  91. }
  92.  
  93. private void dtndividir_Click(object sender, EventArgs e)
  94. {
  95. v1 = Convert.ToDouble(txtvisor.Text);
  96. txtvisor.Clear();
  97. operacao = '/';
  98. }
  99.  
  100. private void btnigual_Click(object sender, EventArgs e)
  101. {
  102. v2 = Convert.ToDouble(txtvisor.Text);
  103. if(operacao == '+')
  104. {
  105. total = v1 + v2;
  106. txtvisor.Text = Convert.ToString(total);
  107. }
  108.  
  109.  
  110. if (operacao == '-')
  111. {
  112. total = v1 - v2;
  113. txtvisor.Text = Convert.ToString(total);
  114. }
  115.  
  116. if (operacao == '*')
  117. {
  118. total = v1 * v2;
  119. txtvisor.Text = Convert.ToString(total);
  120. }
  121.  
  122. if (operacao == '/')
  123. {
  124. total = v1 / v2;
  125. txtvisor.Text = Convert.ToString(total);
  126. }
  127.  
  128. total = Math.Pow(v1, v2);
  129. txtvisor.Text = Convert.ToString(total);
  130.  
  131. if (operacao == '%')
  132. {
  133.  
  134. total = v1 * v2 / 100;
  135. txtvisor.Text = Convert.ToString(total);
  136.  
  137. }
  138. }
  139.  
  140. private void btnlimpar_Click(object sender, EventArgs e)
  141. {
  142. txtvisor.Clear();
  143. }
  144.  
  145. private void btnpotenciaa_Click(object sender, EventArgs e)
  146. {
  147. v1 = Convert.ToDouble(txtvisor.Text);
  148. txtvisor.Clear();
  149. operacao = '^';
  150. }
  151.  
  152. private void btnporcentagem_Click(object sender, EventArgs e)
  153. {
  154. v1 = Convert.ToDouble(txtvisor.Text);
  155. txtvisor.Clear();
  156. operacao = '%';
  157. }
  158.  
  159. private void seno_Click(object sender, EventArgs e)
  160. {
  161. v1 = Convert.ToDouble(txtvisor.Text);
  162. txtvisor.Clear();
  163. total = Math.Sin(v1);
  164. txtvisor.Text = Convert.ToString(total);
  165. }
  166.  
  167. private void btncosseno_Click(object sender, EventArgs e)
  168. {
  169. v1 = Convert.ToDouble(txtvisor.Text);
  170. txtvisor.Clear();
  171. total = Math.Cos(v1);
  172. txtvisor.Text = Convert.ToString(total);
  173. }
  174.  
  175. private void tangente_Click(object sender, EventArgs e)
  176. {
  177. v1 = Convert.ToDouble(txtvisor.Text);
  178. txtvisor.Clear();
  179. total = Math.Tan(v1);
  180. txtvisor.Text = Convert.ToString(total);
  181. }
  182.  
  183. private void btnlog_Click(object sender, EventArgs e)
  184. {
  185. v1 = Convert.ToDouble(txtvisor.Text);
  186. txtvisor.Clear();
  187. total = Math.Log10(v1);
  188. txtvisor.Text = Convert.ToString(total);
  189. }
  190. }
  191. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement