Loan Calculator
Hey. Ive been struggling with this one. Any ideas why I cant use int instead of double? Expected behaviour is to reduce the remaining sum owed each iteration. This works when using double. When I convert everything to int it returns the same sum for each iteration. import java.util.Scanner; public class Program { public double calculatePercentage(double obtained, double percentage) { // double 10percent = (double)(value*(percentage/100.0f)); double remainder = obtained - (double)(obtained*(percentage/100)); return remainder; } public static void main(String[] args) { //instantiate the pc method Program pc = new Program(); //take a input starting amount Scanner scanner = new Scanner(System.in); System.out.println("Enter an amount: "); double obtained = scanner.nextDouble(); int i = 1; do { double remains = pc.calculatePercentage(obtained, 10.0); System.out.println("The remaining amount of your loan is: " + remains); obtained = pc.calculatePercentage(remains,10.0); i++; } while (i<3); } }