-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
89 lines (70 loc) · 2.85 KB
/
Program.cs
File metadata and controls
89 lines (70 loc) · 2.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CalcM
{
class Program:calculo
{
static void Main(string[] args)
{
int b=0;
bool sair = false;
string msg = "TABELA DE OPERAÇÕES\n\n + = soma,\n - = subtração,\n * = multiplicacao, \n / = divisão, \n ^ = potencia, \n . = raiz";
string operacao;
while (!sair) {
Console.WriteLine();
Console.WriteLine(msg);
Console.Write("\n digite o primeiro numero:");
int a = int.Parse(Console.ReadLine());
Console.Write("digite o numero da operação desejada:");
operacao = Console.ReadLine();
var c = new calculo();
//enquanto a operação for falsa
while (c.valida_operacao(operacao)==false)
{
Console.Write("Favor selecionar alguma operação válida:");
operacao = Console.ReadLine();
}
if (operacao!="."){
Console.Write("digite o segundo numero:");
b = int.Parse(Console.ReadLine());
}
switch (operacao){
case "+":
Console.Write("O resultado é: " + c.soma(a, b));
break;
case "-":
Console.Write("O resultado é: " + c.subtracao(a, b));
break;
case "*":
Console.Write("O resultado é: " + c.multiplicacao(a, b));
break;
case "/":
Console.Write("O resultado é: " + c.divisao(a, b));
break;
case "^":
Console.Write("O resultado é: " + c.potencia(a, b));
break;
case ".":
Console.Write("O resultado é: " + c.raiz(a));
break;
}
Console.Write("\nDeseja sair? \nDigite y para sim e n para não:");
string opcao = Console.ReadLine();
switch (opcao)
{
case "y":
sair = true;
break;
default:
sair = false;
break;
}
Console.WriteLine("\n\n");
Console.Clear();
}
}
}
}