Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Basics
- {
- class Program
- {
- static void Main(string[] args)
- {
- DoMaths(); // meh, lets just go with it idc tbh
- while(AskStuff()) { DoMaths(); }
- Console.WriteLine("Aight bouta head out fam");
- Console.ReadLine();
- }
- static bool AskStuff()
- {
- bool meh = true;
- Console.WriteLine("Que ações desejas tomar?");
- Console.WriteLine("1) Voltar ao inicio;");
- Console.WriteLine("2) Sair da aplicação;");
- Console.WriteLine("")
- Console.WriteLine("Opção Escolhida: ");
- actions = Convert.ToInt32(Console.ReadLine());
- switch (actions)
- {
- case 1:
- Console.Clear();
- meh = true;
- break;
- case 2:
- meh = false;
- break;
- }
- return meh;
- }
- static void DoMaths()
- {
- // what about decimal numbers tho?
- int num1 = 0;
- int num2 = 0;
- int operation = 0;
- int result = 0;
- Console.WriteLine("Escolha a operação que deseja realizar:");
- Console.WriteLine("1) Soma;");
- Console.WriteLine("2) Subtração;");
- Console.WriteLine("3) Multiplicação;")
- Console.WriteLine("4) Divisão;");
- Console.WriteLine("")
- Console.WriteLine("Opção Escolhida: ");
- while (!operation)
- {
- try
- operation = Convert.ToInt32(Console.ReadLine());
- catch
- Console.WriteLine("Introduziste um input inválido ou ocorreu um erro.\n");
- }
- switch (operation)
- {
- case 1:
- Console.WriteLine("\nIntroduza o primeiro número:");
- num1 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("\nIntroduza o segundo número:");
- num2 = Convert.ToInt32(Console.ReadLine());
- result = num1 + num2;
- Console.WriteLine("\nA soma destes dois números é: " + result);
- Console.ReadLine();
- break;
- case 2:
- Console.WriteLine("\nIntroduza o primeiro número:");
- num1 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("\nIntroduza o segundo número:");
- num2 = Convert.ToInt32(Console.ReadLine());
- result = num1 - num2;
- Console.WriteLine("\nA subtração destes dois números é: " + result);
- Console.ReadLine();
- break;
- case 3:
- Console.WriteLine("\nIntroduza o primeiro número:");
- num1 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("\nIntroduza o segundo número:");
- num2 = Convert.ToInt32(Console.ReadLine());
- result = num1 * num2;
- Console.WriteLine("\nA multiplicação destes dois números é: " + result);
- Console.ReadLine();
- break;
- case 4:
- Console.WriteLine("\nIntroduza o primeiro número:");
- num1 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("\nIntroduza o segundo número:");
- num2 = Convert.ToInt32(Console.ReadLine());
- result = num1 / num2;
- Console.WriteLine("\nA divisão destes dois números é: " + result);
- Console.ReadLine();
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement