0

I need a help, solve this code for me

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 x = 1, x<= 6; x++){ amount = amount *9/10; } System.out.printIn(amount); } }

15th Sep 2021, 7:25 AM
Christian O. Marvellous JP
Christian O. Marvellous JP - avatar
9 Answers
+ 1
What needs to be solved?
15th Sep 2021, 7:28 AM
Tim
Tim - avatar
+ 1
This is the question: 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 3 months. Sample Input: 20000 Sample Output: 10628 Here is the monthly payment schedule: Month 1 Payment: 10% of 20000 = 2000 Remaining amount: 18000 Month 2 Payment: 10% of 18000 = 1800 Remaining amount: 16200 Month 3: Payment: 10% of 16200 = 1620 Remaining amount: 14580
15th Sep 2021, 9:15 AM
Christian O. Marvellous JP
Christian O. Marvellous JP - avatar
+ 1
you need to enter 3 values amount as 20000 month as 3 and payment amount as 10 https://code.sololearn.com/cHo5ye1BG8DO/?ref=app
15th Sep 2021, 9:16 AM
Parith (Faree)
Parith (Faree) - avatar
0
When running the code, it will give an error message
15th Sep 2021, 7:30 AM
Christian O. Marvellous JP
Christian O. Marvellous JP - avatar
0
int x = 1; (comma should be replaced with semicolon) printIn --> it should be println (small letter of "L" not "I") 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 x = 1; x<= 6; x++){ amount = amount *9/10; } System.out.println(amount); } }
15th Sep 2021, 7:54 AM
Parith (Faree)
Parith (Faree) - avatar
0
Thank you
15th Sep 2021, 9:11 AM
Christian O. Marvellous JP
Christian O. Marvellous JP - avatar
0
But, for this code coach assignment are the 3 months and 10% are fixed. So don't use any input therefore.
15th Sep 2021, 10:24 AM
Coding Cat
Coding Cat - avatar
0
U can remove that input scan and hardcode what u required
15th Sep 2021, 12:56 PM
Parith (Faree)
Parith (Faree) - avatar
0
Remove the comma after 1 in the loop initialization.
16th Sep 2021, 9:12 AM
Saju
Saju - avatar