Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace trabalho_calculadora_ok_
- {
- public partial class Form1 : Form
- {
- double v1, v2, total;
- char operacao;
- public Form1()
- {
- InitializeComponent();
- }
- private void btn1_Click(object sender, EventArgs e)
- {
- txtvisor.Text = txtvisor.Text + 1;
- }
- private void btn2_Click(object sender, EventArgs e)
- {
- txtvisor.Text = txtvisor.Text + 2;
- }
- private void btn3_Click(object sender, EventArgs e)
- {
- txtvisor.Text = txtvisor.Text + 3;
- }
- private void btn4_Click(object sender, EventArgs e)
- {
- txtvisor.Text = txtvisor.Text + 4;
- }
- private void btn5_Click(object sender, EventArgs e)
- {
- txtvisor.Text = txtvisor.Text + 5;
- }
- private void btn6_Click(object sender, EventArgs e)
- {
- txtvisor.Text = txtvisor.Text + 6;
- }
- private void btn7_Click(object sender, EventArgs e)
- {
- txtvisor.Text = txtvisor.Text + 7;
- }
- private void btn8_Click(object sender, EventArgs e)
- {
- txtvisor.Text = txtvisor.Text + 8;
- }
- private void btn9_Click(object sender, EventArgs e)
- {
- txtvisor.Text = txtvisor.Text + 9;
- }
- private void btn0_Click(object sender, EventArgs e)
- {
- txtvisor.Text = txtvisor.Text + 0;
- }
- private void btnmais_Click(object sender, EventArgs e)
- {
- v1 = Convert.ToDouble(txtvisor.Text);
- txtvisor.Clear();
- operacao = '+';
- }
- private void btnmenos_Click(object sender, EventArgs e)
- {
- v1 = Convert.ToDouble(txtvisor.Text);
- txtvisor.Clear();
- operacao = '-';
- }
- private void btnvezes_Click(object sender, EventArgs e)
- {
- v1 = Convert.ToDouble(txtvisor.Text);
- txtvisor.Clear();
- operacao = '*';
- }
- private void dtndividir_Click(object sender, EventArgs e)
- {
- v1 = Convert.ToDouble(txtvisor.Text);
- txtvisor.Clear();
- operacao = '/';
- }
- private void btnigual_Click(object sender, EventArgs e)
- {
- v2 = Convert.ToDouble(txtvisor.Text);
- if(operacao == '+')
- {
- total = v1 + v2;
- txtvisor.Text = Convert.ToString(total);
- }
- if (operacao == '-')
- {
- total = v1 - v2;
- txtvisor.Text = Convert.ToString(total);
- }
- if (operacao == '*')
- {
- total = v1 * v2;
- txtvisor.Text = Convert.ToString(total);
- }
- if (operacao == '/')
- {
- total = v1 / v2;
- txtvisor.Text = Convert.ToString(total);
- }
- total = Math.Pow(v1, v2);
- txtvisor.Text = Convert.ToString(total);
- if (operacao == '%')
- {
- total = v1 * v2 / 100;
- txtvisor.Text = Convert.ToString(total);
- }
- }
- private void btnlimpar_Click(object sender, EventArgs e)
- {
- txtvisor.Clear();
- }
- private void btnpotenciaa_Click(object sender, EventArgs e)
- {
- v1 = Convert.ToDouble(txtvisor.Text);
- txtvisor.Clear();
- operacao = '^';
- }
- private void btnporcentagem_Click(object sender, EventArgs e)
- {
- v1 = Convert.ToDouble(txtvisor.Text);
- txtvisor.Clear();
- operacao = '%';
- }
- private void seno_Click(object sender, EventArgs e)
- {
- v1 = Convert.ToDouble(txtvisor.Text);
- txtvisor.Clear();
- total = Math.Sin(v1);
- txtvisor.Text = Convert.ToString(total);
- }
- private void btncosseno_Click(object sender, EventArgs e)
- {
- v1 = Convert.ToDouble(txtvisor.Text);
- txtvisor.Clear();
- total = Math.Cos(v1);
- txtvisor.Text = Convert.ToString(total);
- }
- private void tangente_Click(object sender, EventArgs e)
- {
- v1 = Convert.ToDouble(txtvisor.Text);
- txtvisor.Clear();
- total = Math.Tan(v1);
- txtvisor.Text = Convert.ToString(total);
- }
- private void btnlog_Click(object sender, EventArgs e)
- {
- v1 = Convert.ToDouble(txtvisor.Text);
- txtvisor.Clear();
- total = Math.Log10(v1);
- txtvisor.Text = Convert.ToString(total);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement