+ 1
Loan calculator
How is this wrong? If it gives the output it's asking for? Can't get them 50xp! import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //tu código va aquí System.out.println (amount); int i = 0; for(i = 0 ; i < 3; i++ ) { amount = amount - (amount *10)/100;; System.out.println(amount ); } } }
3 Respostas
+ 4
You need to print the final amount outside loop.
Also, it's not necessary to print the input amount.
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int amount = scanner.nextInt();
//tu código va aqu
//System.out.println (amount);
int i = 0;
for(i = 0 ; i < 3; i++ )
{
amount = amount - (amount *10)/100;
}
System.out.println(amount );
}
}
+ 2
OMG! it worked... Guess it only wanted the final output. That's why I had it inside the loop. And also that's why I printed the amount first. Thanks dude!