0

error

import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //your code goes here for (int i=0;i<6;i++){ int remainder=amount*9/10; }System.out.println(remainder); } } You take a loan from a friend and need to calculate how much you will owe him after 3 months. You are going to pay him back 10% of the remaining loan amount each month. Create a program that takes the loan amount as input, calculates and outputs the remaining amount after 6 months. Sample Input: 20000 Sample Output: 10628 hi guys i wrote a program for above question but i saw error on running this program. what's my wrong?

1st Jul 2022, 7:41 AM
Hossein
1 Answer
0
Variable int <remainder> is defined within the for...loop. It is only recognised inside the loop. You can instead, work with <amount> directly. Try to put this in the loop amount -= ( amount * 0.1 );
1st Jul 2022, 10:54 AM
Ipang