-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathExemplo3.cs
35 lines (31 loc) · 953 Bytes
/
Exemplo3.cs
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
using System;
namespace MeuNamespace
{
public class MinhaClasse
{
static void Main()
{
Console.Write("Informe um número para A entre 0 e 100: ");
string input1 = Console.ReadLine();
Console.Write("Informe um número para B entre 0 e 100: ");
string input2 = Console.ReadLine();
int num1 = 0;
int num2 = 0;
if (int.TryParse(input1, out num1) && int.TryParse(input2, out num2) && (num1 >= 0 && num1 <= 100) && (num2 >= 0 && num2 <= 100))
{
int result = num1 + num2;
Console.WriteLine("A) " + num1);
Console.WriteLine("B) " + num2);
Console.WriteLine("Resultado: " + result);
}
else
{
Console.WriteLine("Ocorreu um problema. Um dos números informados não eram validos ou não eram números inteiros.");
Console.WriteLine("A) " + num1);
Console.WriteLine("B) " + num2);
}
Console.WriteLine("Pressione qualquer tecla para continuar...");
Console.ReadKey();
}
}
}