+ 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); } } }
8 Antworten
+ 3
Hope this helps you
+ 1
https://www.sololearn.com/discuss/2604391/?ref=app
https://www.sololearn.com/discuss/2681400/?ref=app
https://www.sololearn.com/discuss/2680282/?ref=app
https://www.sololearn.com/discuss/2660363/?ref=app
https://www.sololearn.com/discuss/2737889/?ref=app
https://www.sololearn.com/discuss/2670258/?ref=app
https://www.sololearn.com/discuss/2610459/?ref=app
https://www.sololearn.com/discuss/2605192/?ref=app
+ 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);
}
}
+ 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.... :-)☺☺☺
+ 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
+ 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 );
}
}
}
0
thank you
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);
}
}