0
What's wrong in this program?
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int initialAmount = scanner.nextInt(); //your code goes here int remainingAmount = initialAmount; int months = 0; for(months = 0; months <= 5; months++){ int payment = (remainingAmount * 10) /100; remainingAmount = remainingAmount - payment; } System.out.println(remainingAmount ); } }
8 ответов
+ 1
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int initialAmount = scanner.nextInt();
//your code goes here
int remainingAmount = initialAmount;
int months = 0;
for(months = 0; months <3; months++){
int payment = (remainingAmount * 10) /100;
remainingAmount = remainingAmount - payment;
}
System.out.println(remainingAmount );
}
}
+ 1
You have to calculate it for 3 months
+ 1
Use this
for(months = 0; months <= 2; months++){
because we only have to calculate for 3 months
See here:
"You take a loan from a friend and need to calculate how much you will owe him after 3 months."
+ 1
I think so the question is changed after the update. If you update your app and read the question again you will get to know that it is written 3 months
0
I tried a lot of times but I couldn't find what's the mistake
0
Why we have to take 3 months
0
Sandeep Kumar
Just do this
for (months = 0; months <= 5; months++) {
initialAmount = initialAmount * 90 / 100;
}
System.out.println(initialAmount);
0
Got the output TQ u guys for helping me