0% found this document useful (0 votes)
32 views5 pages

Operaciones

This C# program asks the user to input two numbers, then displays a menu for the user to select an arithmetic operation to perform on those numbers - addition, subtraction, multiplication, or division. It will calculate and display the result, catching exceptions for non-numeric input or divide by zero errors. The program loops, allowing the user to continue entering new numbers and selecting operations until they enter "no" to quit.

Uploaded by

Deimer Romero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views5 pages

Operaciones

This C# program asks the user to input two numbers, then displays a menu for the user to select an arithmetic operation to perform on those numbers - addition, subtraction, multiplication, or division. It will calculate and display the result, catching exceptions for non-numeric input or divide by zero errors. The program loops, allowing the user to continue entering new numbers and selecting operations until they enter "no" to quit.

Uploaded by

Deimer Romero
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

static void Main(string[]

args)
{
string rta = "si";
do
{
try
{
Console.WriteLine("DIGITE UN
NUMERO");
int a =
int.Parse(Console.ReadLine());
Console.WriteLine("digite otro
numero");
int b =
int.Parse(Console.ReadLine());

Console.WriteLine("QUE DESEA
HACER");
Console.WriteLine("***********
********************** ");
Console.WriteLine("******** 1.
SUMARLOS ******** ");
Console.WriteLine("******** 2.
RESTARLOS ******** ");
Console.WriteLine("******** 3.
MULTIPLICARLOS******* ");
Console.WriteLine("******** 4.
DIVIDIRLOS ******* ");
Console.WriteLine("***********
********************** ");
Console.WriteLine("ESCOJA SU
OPCION < 1-4 >");
int OPCION
=
int.Parse(Console.ReadLine());

switch
(OPCION)
{
case
1:
Console.WriteLine("la suma de
{0} + {1} = {2}", a, b, a +
b);
break;
case
2:
Console.WriteLine("la
diferencia de {0} - {1} =
{2}", a, b, a - b);
break;
case
3:
Console.WriteLine("la
multiplicacion de {0} * {1}
={2}", a, b, a * b);
break;
case
4:
Console.WriteLine("la division
de {0} / {1} = {2}", a, b, a /
b);
break;
default:
Console.WriteLine("DEBE
ESCOGER ENTRE 1 A 4");
break;
}
}
catch
(FormatException)
{
Console.WriteLine("debe ser un
entero");
}
catch
(DivideByZeroException)
{
Console.WriteLine("El segundo
debe ser diferente de 0");
}
Console.WriteLine("Desea
continuar?");
rta =
Console.ReadLine();
} while (rta ==
"si");
}

You might also like