Convertion to double

This commit is contained in:
Tiago Garcia 2023-02-25 19:23:55 +00:00 committed by GitHub
commit 9455ead13c
Signed by untrusted user who does not match committer: TiagoRG
GPG Key ID: DFCD48E3F420DB42
1 changed files with 2 additions and 2 deletions

View File

@ -9,7 +9,7 @@ public class Investment {
public static void main(String[] args) { public static void main(String[] args) {
Scanner sin = new Scanner(System.in); Scanner sin = new Scanner(System.in);
int investment; double investment;
do { do {
System.out.print("Introduza o investimento inicial (múltiplo de 1000): "); System.out.print("Introduza o investimento inicial (múltiplo de 1000): ");
investment = sin.nextInt(); investment = sin.nextInt();
@ -20,7 +20,7 @@ public class Investment {
for (int i = 1; i <= 12; i++) { for (int i = 1; i <= 12; i++) {
investment *= 1+tax/100; investment *= 1+tax/100;
System.out.printf("Investimento em %d %s: %d\n", i, i==1?"mês":"meses", investment); System.out.printf("Investimento em %d %s: %.2f\n", i, i==1?"mês":"meses", investment);
} }
sin.close(); sin.close();