1
I need to calculate the root and power according to the logic that follows.. so far ta funfando
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 calculadora
{
    public partial class Form1 : Form
    {
        Double value = 0;
        String operacao = "";
        bool operacao_press = false;
        public Form1()
        {
            InitializeComponent();
        }
        private void button_Click(object sender, EventArgs e)
        {
            if ((resultado.Text == "0") || (operacao_press))
                resultado.Clear();
            Button b = (Button)sender;
            resultado.Text = resultado.Text + b.Text;
        }
        private void button16_Click(object sender, EventArgs e)
        {
            resultado.Text = "0";
        }
        private void button20_Click(object sender, EventArgs e)
        {
            resultado.Text = "0";
        }
        private void operador_click(object sender, EventArgs e)
        {
            Button b = (Button)sender;
            operacao = b.Text;
            value = Double.Parse(resultado.Text);
            operacao_press = true;
        }
        private void button18_Click(object sender, EventArgs e)
        {                              
            switch (operacao) //OPERAÇÕES MATEMÁTICAS   
            {         
                case "+":
                    resultado.Text = (value + Double.Parse(resultado.Text)).ToString();
                    break;
                case "- ":
                    resultado.Text = (value - Double.Parse(resultado.Text)).ToString();
                    break;
                case "/":
                    resultado.Text = (value / Double.Parse(resultado.Text)).ToString();
                    break;
                case "*":
                    resultado.Text = (value * Double.Parse(resultado.Text)).ToString();
                    break;
                case "RAIZ":
                    resultado.Text = (value  Double.Parse(resultado.Text)).ToString();
                    break;
                case "POTENCIALIZAÇÃO":
                    resultado.Text = (value  Double.Parse(resultado.Text)).ToString();
                    break;
                default:
                    break;
            } //Final do Switch
            operacao_press = false;
        }
    }
}
						
No need to convert to string back no?
– Jefferson Quesado
@Jeffersonquesado edited the answer.
– CypherPotato
this root of the other exponent fits inside the switch ?
– user93935
In the case of roots of other exponents, it would not be the case to do
1.0/expoente? I believe that C# uses integer division (unlike Python 3 which always goes to rational division, whole division being another operator)– Jefferson Quesado
@jaogui_ I organized a little the answer of Cypherpotato, it should help in that doubt
– Jefferson Quesado
@Cypherpotato, I beg your permission to give a little tidying up, if you have changed the meaning of the answer, I ask for a tug of an ear and forgiveness
– Jefferson Quesado
thanks, already helped out !
– user93935
Quiet @Jeffersonquesado, editions are welcome.
– CypherPotato