107 lines
2.3 KiB
C#
107 lines
2.3 KiB
C#
using System;
|
|
using System.Reflection;
|
|
|
|
namespace exercicios
|
|
{
|
|
class Exercicio5
|
|
{
|
|
public static void Init()
|
|
{
|
|
string sel = "";
|
|
|
|
Console.WriteLine("Select an operation:"+
|
|
"\n1 - Sum"+
|
|
"\n2 - Subtract"+
|
|
"\n3 - Divide"+
|
|
"\n4 - Multiply"+
|
|
"\n5 - Div. Remains"+
|
|
"\n6 - Double"+
|
|
"\n7 - Squared"+
|
|
"\n8 - Cubed"+
|
|
"\n9 - Square Root"+
|
|
"\n0 - Exit");
|
|
|
|
sel = Console.ReadLine();
|
|
if(sel != "0"){
|
|
Console.WriteLine("Insert a value and press Enter (2)");
|
|
Type typesPrograma = typeof(Exercicio5);
|
|
MethodInfo aInvocar = typesPrograma.GetMethod(
|
|
"op"+sel, BindingFlags.Static | BindingFlags.NonPublic);
|
|
aInvocar.Invoke(null, null);
|
|
}
|
|
}
|
|
static void op1()
|
|
{
|
|
int i, i2;
|
|
i = int.Parse(Console.ReadLine());
|
|
i2 = int.Parse(Console.ReadLine());
|
|
|
|
Console.WriteLine("{0} + {1} = {2}",i,i2,i+i2);
|
|
}
|
|
static void op2()
|
|
{
|
|
int i, i2;
|
|
i = int.Parse(Console.ReadLine());
|
|
i2 = int.Parse(Console.ReadLine());
|
|
|
|
Console.WriteLine("{0} - {1} = {2}",i,i2,i-i2);
|
|
}
|
|
static void op3()
|
|
{
|
|
int i, i2;
|
|
i = int.Parse(Console.ReadLine());
|
|
i2 = int.Parse(Console.ReadLine());
|
|
|
|
Console.WriteLine("{0} / {1} = {2:N2}",i,i2,(double)i/i2);
|
|
}
|
|
static void op4()
|
|
{
|
|
int i, i2;
|
|
i = int.Parse(Console.ReadLine());
|
|
i2 = int.Parse(Console.ReadLine());
|
|
|
|
Console.WriteLine("{0} * {1} = {2}",i,i2,i*i2);
|
|
}
|
|
static void op5()
|
|
{
|
|
int i, i2;
|
|
i = int.Parse(Console.ReadLine());
|
|
i2 = int.Parse(Console.ReadLine());
|
|
|
|
Console.WriteLine("{0} % {1} = {2}",i,i2,(double)i%i2);
|
|
}
|
|
static void op6()
|
|
{
|
|
int i;
|
|
i = int.Parse(Console.ReadLine());
|
|
|
|
Console.WriteLine("{0}*2 = {1}",i,i*2);
|
|
}
|
|
static void op7()
|
|
{
|
|
int i;
|
|
i = int.Parse(Console.ReadLine());
|
|
|
|
Console.WriteLine("{0}^2 = {1}",i,i*i);
|
|
}
|
|
static void op8()
|
|
{
|
|
int i;
|
|
i = int.Parse(Console.ReadLine());
|
|
Console.WriteLine("{0}^3 = {1}",i,i*i*i);
|
|
|
|
}
|
|
static void op9()
|
|
{
|
|
int i;
|
|
i = int.Parse(Console.ReadLine());
|
|
|
|
Console.WriteLine("Sqrt({0}) = {1}",i,Math.Sqrt(i));
|
|
}
|
|
static void op10()
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|