Social Icons

Mostrando las entradas con la etiqueta CALCULADORA. Mostrar todas las entradas
Mostrando las entradas con la etiqueta CALCULADORA. Mostrar todas las entradas

viernes, 5 de agosto de 2022

Calculadora en c#

Este es un proyecto de una Calculadora en WPF :





==================================================================
//Codigo archivo: MainWindows.xaml
=============================================================
<Window x:Class="CalculadoraWPF.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:CalculadoraWPF"
        mc:Ignorable="d"
        Title="Calculadora WPF" Height="400" Width="355">
    <Grid>
        <TextBox x:Name="Textbox_Screen" IsReadOnly="True" TextAlignment="Right" VerticalContentAlignment="Center" HorizontalAlignment="Left" Height="50" Margin="15,28,0,0" TextWrapping="NoWrap" VerticalAlignment="Top" Width="310" FontSize="40" FontWeight="Bold" MaxLength="15" MaxLines="15"/>
        <Button Content="7" HorizontalAlignment="Left" Margin="15,105,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Siete" FontSize="24" FontWeight="Bold"/>
        <Button Content="/" HorizontalAlignment="Left" Margin="210,300,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Dividir" FontSize="24" FontWeight="Bold"/>
        <Button Content="*" HorizontalAlignment="Left" Margin="210,235,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Multiplicar" FontWeight="Bold" FontSize="24"/>
        <Button Content="-" HorizontalAlignment="Left" Margin="210,170,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Restar" FontSize="24" FontWeight="Bold"/>
        <Button Content="=" HorizontalAlignment="Left" Margin="145,300,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Igual" FontSize="24" FontWeight="Bold"/>
        <Button Content="3" HorizontalAlignment="Left" Margin="145,235,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Tres" FontSize="24" FontWeight="Bold"/>
        <Button Content="6" HorizontalAlignment="Left" Margin="145,170,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Seis" FontSize="24" FontWeight="Bold"/>
        <Button Content="." HorizontalAlignment="Left" Margin="80,300,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Punto" FontSize="24" FontWeight="Bold"/>
        <Button Content="2" HorizontalAlignment="Left" Margin="80,235,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Dos" FontWeight="Bold" FontSize="24"/>
        <Button Content="5" HorizontalAlignment="Left" Margin="80,170,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Cinco" FontSize="24" FontWeight="Bold"/>
        <Button Content="0" HorizontalAlignment="Left" Margin="15,301,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Cero" FontSize="24" FontWeight="Bold"/>
        <Button Content="1" HorizontalAlignment="Left" Margin="15,235,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Uno" FontSize="24" FontWeight="Bold"/>
        <Button Content="4" HorizontalAlignment="Left" Margin="15,170,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Cuatro" FontSize="24" FontWeight="Bold"/>
        <Button Content="8" HorizontalAlignment="Left" Margin="80,105,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Ocho" FontSize="24" FontWeight="Bold"/>
        <Button Content="9" HorizontalAlignment="Left" Margin="145,105,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Nueve" FontSize="24" FontWeight="Bold"/>
        <Button Content="+" HorizontalAlignment="Left" Margin="210,105,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Sumar" FontSize="24" FontWeight="Bold"/>
        <Button Content="C" HorizontalAlignment="Left" Margin="275,105,0,0" VerticalAlignment="Top" Width="50" Height="50" Click="Presiona_Clear" FontSize="24" FontWeight="Bold"/>
    </Grid>
</Window>

==================================================================
//Codigo archivo: MainWindows.xaml.cs
=============================================================

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using System.Windows;

using System.Windows.Controls;

using System.Windows.Data;

using System.Windows.Documents;

using System.Windows.Input;

using System.Windows.Media;

using System.Windows.Media.Imaging;

using System.Windows.Navigation;

using System.Windows.Shapes;


namespace CalculadoraWPF

{

    /// <summary>

    /// Interaction logic for MainWindow.xaml

    /// </summary>

    public partial class MainWindow : Window

    {

        double primera_Entrada;

        double segunda_Entrada;

        double resultado;

        string operador;


        public MainWindow()

        {

            InitializeComponent();

        }


        private void Presiona_Cero(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Text = Textbox_Screen.Text + "0"; 

        }


        private void Presiona_Uno(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Text = Textbox_Screen.Text + "1";

        }


        private void Presiona_Dos(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Text = Textbox_Screen.Text + "2";

        }


        private void Presiona_Tres(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Text = Textbox_Screen.Text + "3";

        }


        private void Presiona_Cuatro(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Text = Textbox_Screen.Text + "4";

        }


        private void Presiona_Cinco(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Text = Textbox_Screen.Text + "5";

        }


        private void Presiona_Seis(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Text = Textbox_Screen.Text + "6";

        }


        private void Presiona_Siete(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Text = Textbox_Screen.Text + "7";

        }


        private void Presiona_Ocho(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Text = Textbox_Screen.Text + "8";

        }


        private void Presiona_Nueve(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Text = Textbox_Screen.Text + "9";

        }


        private void Presiona_Sumar(object sender, RoutedEventArgs e)

        {

            operador = "+";

            primera_Entrada = double.Parse(Textbox_Screen.Text);

            Textbox_Screen.Clear();

        }


        private void Presiona_Restar(object sender, RoutedEventArgs e)

        {

            operador = "-";

                primera_Entrada = double.Parse(Textbox_Screen.Text);

                Textbox_Screen.Clear();

        }


        private void Presiona_Multiplicar(object sender, RoutedEventArgs e)

        {

            operador = "*";

            primera_Entrada = double.Parse(Textbox_Screen.Text);

            Textbox_Screen.Clear();

        }


        private void Presiona_Dividir(object sender, RoutedEventArgs e)

        {

            operador = "/";

            primera_Entrada = double.Parse(Textbox_Screen.Text);

            Textbox_Screen.Clear();

        }


        private void Presiona_Punto(object sender, RoutedEventArgs e)

        {

            if (Textbox_Screen.Text.Contains("."))

            {


            }

            else

            {

                Textbox_Screen.Text = Textbox_Screen.Text + ".";

            }

        }


        private void Presiona_Igual(object sender, RoutedEventArgs e)

        {

            segunda_Entrada = double.Parse(Textbox_Screen.Text);

            switch (operador)

            {

                case "+":

                    resultado = primera_Entrada + segunda_Entrada;

                    Textbox_Screen.Text = resultado.ToString();

                    break;

                case "-":

                    resultado = primera_Entrada - segunda_Entrada;

                    Textbox_Screen.Text = resultado.ToString();

                    break;

                case "*":

                    resultado = primera_Entrada * segunda_Entrada;

                    Textbox_Screen.Text = resultado.ToString();

                    break;

                case "/":

                    resultado = primera_Entrada / segunda_Entrada;              

                    Textbox_Screen.Text = resultado.ToString();

                    break;

            }

        }


        private void Presiona_Clear(object sender, RoutedEventArgs e)

        {

            Textbox_Screen.Clear();

        }

    }

}


viernes, 29 de julio de 2022

Calculadora en C# Visual 2022

 using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace Calcular_Soma_Subtração_Multiplicação_Divisão

{

    internal class Program

    {

        static void Main(string[] args)

        {


            Console.Title = "Calculadora Simples";


            int numero1, numero2, resultado = 0;



            string operacao;




            Console.WriteLine("Digite o primeiro número: ");

            numero1 = int.Parse(Console.ReadLine());


            Console.WriteLine("Digite o segundo número: ");

            numero2 = int.Parse(Console.ReadLine());


            Console.WriteLine("Digite a operação: ");

            operacao = Console.ReadLine();  



            // Realizando as Operações



            switch (operacao)

            {

                case "+":

                    resultado = numero1 + numero2;

                    break;


                case "-":

                    resultado = numero1 - numero2;

                    break;


                case "*":

                    resultado = numero1 * numero2;

                    break;


                case "/":

                    resultado = numero1 / numero2;

                    break;


                default:

                    Console.WriteLine("Operação Inválida");

                    break;


            }


            Console.WriteLine("Resultado: " + numero1 + " " + operacao + " " + numero2 + " " + "=" + " " + resultado );


     







            Console.ReadKey();

        }

    }

}


jueves, 14 de julio de 2022

Calculadora en c#

 using System;


namespace _1._5

{

    class Program

    {

        static void Main(string[] args)

        {

            float num1, num2;

            float resultado=0.0f;

            int opcion;

            Console.WriteLine("Calculadora de 2 Numeros");

            Console.WriteLine("Ingrese el primer número");

            num1 = Convert.ToSingle(Console.ReadLine());

            Console.WriteLine("Ingrese el segundo número");

            num2 = Convert.ToSingle(Console.ReadLine());

            Console.WriteLine("Operaciones Permitidas");

            Console.WriteLine("1) Suma");

            Console.WriteLine("2) Resta");

            Console.WriteLine("3) Multiplicacion");

            Console.WriteLine("4) Division");

            Console.WriteLine("Ingrese la Opción");

            opcion = Convert.ToInt32(Console.ReadLine());


        switch(opcion)

            {

                case 1:

                    resultado =num1 + num2;

                    

                    break;


                case 2:

                    resultado = num1 - num2;


                    break;

                case 3:

                    resultado = num1 * num2;


                    break;

                    

                default:

                    Console.WriteLine("Opción Incorrecta");

                    break;

            }

            if (resultado != 0) 

                Console.WriteLine("El Resultado es:{0}", resultado);


        }

    }


}

Data Analyzer Error Excel

Error en copiar las celdas no se abre el Excel:  Haz clic en YES (Sí) en el mensaje de error y busca manualmente el archivo EXCEL.exe. Depen...

 
 
Blogger Templates