0
Java 2 error Loan Calculator
I am not sure what it is happing.. This is my code I did the same excersice in my computer and the error are the decimals import java.util.Scanner; public class Program { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int amount = scanner.nextInt(); //tu cĂłdigo va aquĂ int x=1,z=0; while(x<=6){ z= amount*10/100; amount = amount - z; x++; } System.out.println(amount); } }
12 Respostas
+ 2
Francisco Guadarrama Sanchez
Just do
amount = amount * 90 / 100;
inside while loop
+ 8
I think this will help you.
https://code.sololearn.com/cam4f1R38za2/?ref=app
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 i=0;i<6;i++){
amount -= (amount * 0.1);
}
System.out.println(amount);
}
}
+ 2
double amount = scanner.nextDouble();
//tu cĂłdigo va aquĂ
int x=1,z=0;
while(x<=6){
z= (int)(Math.ceil(amount*10/100));
amount = amount - z;
x++;
}
System.out.println((int)amount);
}
}
+ 2
I Am AJ ! My code is fulfilled all the cases. Just check if my process is correct
+ 2
Atul Your code is also correct. First time I did like that when I was getting difference 1.
+ 2
I Am AJ ! Thanks
+ 1
Make this necessary changes in your code
+ 1
I Am AJ ! It worked perfectly, thank you so much
+ 1
I Am AJ ! Yes, I modified my code with your code I could pass the test đđđ»ââïžthanks
0
I will try it right now