+ 8

Loan Calculator Problem

I need some help. According to this question my input and output have a difference of 1 number in months 5 here is 1313 I have 1312 and rest of the program is okay That is why output is (10629) not as expected. You take a loan from a friend and need to calculate how much you will owe him after 6 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 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 Month 4: Payment: 10% of 14580 = 1458 Remaining amount: 13122 Month 5: Payment: 10% of 13122 = 1313 Remaining amount: 11809 Month 6: Payment: 10% of 11809 = 1181 Remaining amount: 10628 https://code.sololearn.com/cQCKlK9H1NGe/?ref=a

12th Dec 2020, 11:35 AM
Mahad Ahmed
Mahad Ahmed - avatar
45 Réponses
+ 32
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); } }
12th Dec 2020, 11:46 AM
Иван Чикyнов
Иван Чикyнов - avatar
+ 68
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); for (int x = 0; x <3; x++){ int actual_amount = (amount * 10)/100; amount = amount - actual_amount; } System.out.println(amount); } }
31st Mar 2021, 2:51 PM
Prãbîñ Pãñtã
Prãbîñ Pãñtã - avatar
+ 8
for(int x =0;x<3;x++){ amount = amount - (amount * 10/100); } System.out.println(amount); 👍, it was quite easy but took long to revise the concept of logic 😅
15th Dec 2021, 1:44 AM
Nitin Singh
Nitin Singh - avatar
+ 6
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int total = 0; int tenP; //Please Subscribe to My Youtube Channel //Channel Name: Fazal Tuts4U for(int i=0; i<3; i++){ tenP = (amount*10)/100; total = amount - tenP; amount = total; } System.out.println(total); } }
3rd Sep 2021, 5:10 PM
Fazal Haroon
Fazal Haroon - avatar
+ 4
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); for (int x = 0; x <3; x++){ int actual_amount = (amount * 10)/100; amount = amount - actual_amount; } System.out.println(amount); //your code goes here } }
22nd Mar 2021, 8:19 AM
Lalitha E
Lalitha E - avatar
+ 3
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //your code goes here int numOfMonths=1; int payment; int remainingAmount; while(numOfMonths<=3){ payment=(10*amount)/100; remainingAmount=(amount-payment); amount=remainingAmount; numOfMonths++; } System.out.println(amount);
8th Apr 2021, 10:39 AM
Romina
+ 2
Thank You guys I find it very useful to multiply the amount by 9/10 which is almost equal to 0.10 And Maths.ceil() also does the same thing Most interesting part is that dividing the amount by Double or Float 10.0 does the exact same job but not with Int 10?
12th Dec 2020, 12:22 PM
Mahad Ahmed
Mahad Ahmed - avatar
+ 2
I am getting this loan calculator problem. Can anyone copy that code plzzz.
30th Nov 2021, 6:49 AM
Venkata Hyndavi Nanduri
Venkata Hyndavi Nanduri - avatar
+ 1
You calculate the amount for 10% with an integer, which is not so fine. Please analize yourself why? This is important to understand it if you will code in the future for industry. The solution is: for(int x = 0; x < 6; x++) { amount -= amount / 10.0; } System.out.println(amount);
12th Dec 2020, 12:03 PM
JaScript
JaScript - avatar
13th Dec 2020, 5:14 AM
Coder
Coder - avatar
+ 1
whenever I code different code for this question. I got "No output". can you explain the reason for that?
2nd Mar 2021, 5:01 AM
H.A.R.U. Hettiarachchi
H.A.R.U. Hettiarachchi - avatar
+ 1
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 h for(int i=1 ; i<= 3 ; i++){ amount = amount - (amount/ 10); } System.out.println(amount); } } // this is for after 3 month
15th Apr 2021, 11:12 AM
Rai Prashant Ramkishor
Rai Prashant Ramkishor - avatar
+ 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); for (int x = 0; x <3; x++){ int actual_amount = (amount * 10)/100; amount = amount - actual_amount; } System.out.println(amount); } }
21st May 2021, 11:36 AM
Yasiru Dahanayaka
Yasiru Dahanayaka - avatar
+ 1
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 int x = 0; do{ x++; int y = (amount * 10)/100; amount -= y; } while(x < 3); System.out.println(amount); } }
8th Aug 2021, 4:48 PM
Mujtaba Naqvi
Mujtaba Naqvi - avatar
+ 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int total=0; for (int i = 1; i <= 3; i++){ total = amount * 10 / 100; amount=amount-total; } System.out.println(amount); } }
14th Aug 2021, 10:57 AM
Kiran Vellanki
Kiran Vellanki - avatar
+ 1
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 int b=0; for(int a=1;a<=3;a++){ b=amount/10; amount=amount-b; } System.out.print(amount); } }
19th Aug 2021, 5:17 AM
PHANIVISHNU ADDEPALLI
PHANIVISHNU ADDEPALLI - avatar
+ 1
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 = 1; i <=3 ; ++i){ amount = (90 * amount) / 100; } System.out.println(amount); } }
22nd Aug 2021, 8:56 PM
Mwaniki Grace Waigumo
Mwaniki Grace Waigumo - avatar
+ 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int one = (amount * 10)/ 100; amount = amount - one; int two = (amount * 10)/ 100; amount = amount - two; int three = (amount * 10)/ 100; amount = amount - three; System.out.println(amount); (this is the Logic)
5th Sep 2021, 2:55 PM
Ajay Prakash N
Ajay Prakash N - avatar
+ 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); for (int x = 0; x <3; x++){ int actual_amount = (amount * 10)/100; amount = amount - actual_amount; } System.out.println(amount); } }
17th Dec 2021, 9:23 AM
Mirmahmud Ilyosov
Mirmahmud Ilyosov - avatar
+ 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); for (int x = 0; x <3; x++){ int actual_amount = (amount * 10)/100; amount = amount - actual_amount; } System.out.println(amount); //your code goes here } } Good Luck
19th Dec 2021, 2:16 PM
Muhammad Alif Deva Rizqon
Muhammad Alif Deva Rizqon - avatar