Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Bibliotecas
- import 'dart:io';
- // Funcao principal
- main() {
- int i = 1;
- while (true) {
- int resp = menu();
- if (resp == 0) {
- break;
- } else if (resp > 0 && resp < 5) {
- // Entrada de dados
- stdout.write("\n# Tabuada de qual numero: ");
- double n = double.parse(stdin.readLineSync()!);
- print("=====================================");
- // Estrutura de repeticao
- while (i < 11) {
- if (resp == 1) {
- print("# $n + $i = " + (n + i).toStringAsFixed(2));
- } else if (resp == 2) {
- print("# $n - $i = " + (n - i).toStringAsFixed(2));
- } else if (resp == 3) {
- print("# $n / $i = " + (n / i).toStringAsFixed(2));
- } else if (resp == 4) {
- print("# $n * $i = " + (n * i).toStringAsFixed(2));
- }
- // Incremento
- i++;
- }
- print("=====================================");
- i = 1;
- }
- }
- }
- int menu() {
- print("\n===== Menu =====");
- print("[1] Adicao ");
- print("[2] Subtracao");
- print("[3] Divisao");
- print("[4] Multiplicacao");
- print("[0] Exit");
- stdout.write("# Opc: ");
- return int.parse(stdin.readLineSync()!);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement