+ 2
Loan calculator JAVA CODE PROJECT 2.
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 count = 0; double percentage = 0.1; while(count < 3){ int payment = (int) percentage * amount; amount = amount - payment; if(count == 2){ System.out.println(amount); break; } count++; } } } // I have try my best but nothing is coming up.
2 Réponses
+ 4
This line result as:
int payment = (int) percentage * amount;
= (int) 0.1 * amount = 0*amount= 0
Instead use
int payment =(int) (amount * 0.1) ;
+ 2
Wow, thanks man