+ 3

The Loan Calc problem in Java

Hi everyone, I have been trying to solve this loan calc problem for Java. It is for the loops section. Not sure what am I missing here. The hidden test cases fail and. I am unable to complete my certificate since this problem is not solved. Please let me know if any of you faced it also and how did you get it resolved. import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); int i = 0; //your code goes here if (amount > 0){ while( i <3){ amount = amount - (amount/100 * 10); i++; } System.out.println(amount); } } }

13th Apr 2021, 5:21 AM
Sapna Singh
Sapna Singh - avatar
9 odpowiedzi
+ 3
Hope this helps you
13th Apr 2021, 5:23 AM
Atul [Inactive]
+ 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 loan; //your code goes here for(int i=1;i<=3;i++) { loan =amount/10; amount-=loan; } System.out.println(amount); } }
14th Jun 2021, 9:17 AM
Dharmi Sri
Dharmi Sri - avatar
+ 1
import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int amount = sc.nextInt(); for(int months =6; months>0; months--) { amount = amount*90/100; } System.out.println(amount); } } Hope this helps you.... :-)☺☺☺
19th Aug 2021, 5:46 PM
Prabhat
Prabhat - avatar
+ 1
Inside while statement, you should write, amount = amount - (amount*1)/10; The rest of your code is perfect, just change this line Explanation: we are subtracting 10% of amount from amount for 3 months. So, you applied the wrong formula here. Hope you get it...Feel free to ask any question
31st Jul 2022, 2:21 PM
Sayyam Jain
Sayyam Jain - 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 i = 0 ; //your code goes here if (amount>0){ while(i<3){ amount=amount- (amount*10/100); i++; } System.out.println (amount ); } } }
4th Oct 2022, 6:52 PM
Ionut Piturlea
Ionut Piturlea - avatar
0
thank you
15th Apr 2021, 5:02 AM
Sapna Singh
Sapna Singh - avatar
0
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 = 0; x <3; x++){ int actual_amount = (amount * 10)/100; amount = amount - actual_amount; } System.out.println(amount); } }
31st Jan 2022, 9:58 AM
Gaurav Kannaujia