Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Bibliotecas
- import 'dart:io';
- // Funcao principal
- main() {
- // Variaveis
- var opc;
- double a, b;
- // Entrada de dados
- stdout.write("# Primeiro valor: ");
- a = double.parse(stdin.readLineSync()!);
- stdout.write("# Segundo valor: ");
- b = double.parse(stdin.readLineSync()!);
- // Menu
- stdout.writeln("\n# Operacoes matematicas");
- stdout.writeln("# [+] Somar");
- stdout.writeln("# [-] Subtrair");
- stdout.writeln("# [*] Multiplicar");
- stdout.writeln("# [/] Dividir");
- stdout.write("# Opc: ");
- opc = stdin.readLineSync()!;
- // Chamada de metodo
- operacao(a, b, opc);
- }
- // Funcao
- void operacao(double a, double b, var opc) {
- if (opc == "+") {
- print("\n# Soma: " + (a + b).toStringAsFixed(2));
- } else if (opc == "-") {
- print("\n Subtrair: " + (a - b).toStringAsFixed(2));
- } else if (opc == "*") {
- print("\n# Multiplicar: " + (a * b).toStringAsFixed(2));
- } else if (opc == "/") {
- try {
- print("\n# Dividir: " + (a / b).toStringAsFixed(2));
- } catch (e) {
- //print(e);
- }
- } else {
- print("# Opcao invalida !");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement