exercicios do teste

master
João Miranda 2025-11-27 09:19:56 +00:00
parent ef3ac35501
commit 96b6aee7f8
1 changed files with 20 additions and 13 deletions

View File

@ -240,21 +240,28 @@ public class Mavenproject29 {
// } // }
// } // }
// Scanner scanner = new Scanner(System.in);
// double soma = 0;
// double maiorFatura = 0;
// int mes = 0;
// for (int i = 0; i < 12; i++){
// System.out.println("Introduza o valor da fatura " + (i + 1));
// double valor = scanner.nextDouble();
// soma += valor;
// if(valor > maiorFatura){
// maiorFatura = valor;
// mes = i + 1;
// }
// }
// System.out.println("A soma das faturas é " + soma);
// System.out.println("O mês com a maior fatura foi " + mes);
Scanner scanner = new Scanner(System.in); Scanner scanner = new Scanner(System.in);
double soma = 0; System.out.println("Introduza um número");
double maiorFatura = 0; int numero = scanner.nextInt();
int mes = 0; for(int i = 1; i < 11; i++){
for (int i = 0; i < 12; i++){ System.out.println(numero + " x " + i + " = " + (numero * i));
System.out.println("Introduza o valor da fatura " + (i + 1));
double valor = scanner.nextDouble();
soma += valor;
if(valor > maiorFatura){
maiorFatura = valor;
mes = i + 1;
}
} }
System.out.println("A soma das faturas é " + soma);
System.out.println("O mês com a maior fatura foi " + mes);
} }
} }