New course! Every coder should learn Generative AI!
Try a free lesson+ 2
Please help with my code
I'm taking a java course, for finish it is necessary to make a loan calculator, I have three tests well but 2 don't, this is my code. 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<6; ++x){ amount =(amount -(10*amount)/100); } System.out.println(amount-1); } }
2 Answers
+ 1
I could find the solution đ.
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 aux;
for(int i=1;i<=6;i++){
aux = amount/10;
if(amount%10!=0){
aux++;
}
amount = amount - aux;
}
System.out.println(amount);
}
}
+ 3
My solution was similar to Martin Taylor:
for(int i=0; i<6; i++)
{ amount *= 0.9; }