Note that there are some explanatory texts on larger screens.

plurals
  1. PODouble Values Not Showing Calculated Values
    primarykey
    data
    text
    <p>I'm trying to calculate the payment term for the user. I try to crunch the numbers and spit them out, but that's not happening for some reason. However, it displays perfectly fine when I explicitly assign the variables a value while declaring them. </p> <pre><code>public static void creditCardPaymentCalculator() { //User Input Variables Scanner userInput = new Scanner(System.in); //User's Input double purchaseAmount, interestAmount = 0, minimumMonthlyPayment; //Table Counters int[] month = new int[12]; double payment = 0; double monthlyInterest = 0; double principal = 0; double remainingBalance = 0; double yearsOfPayment = 0; int yearCounter = 1; int monthCounter = 0; //Initialize Variables //------------------------------------------------------------------------- //Initialize Month Array for (int i = 0; i &lt; 12; i++) { month[i] = (i + 1); } //------------------------------------------------------------------------- //Welcome Message System.out.println("\n\n\n\nCredit Card Payment Calculator\n\n"); //Get User Input System.out.println("Enter Your Purchase Amount"); purchaseAmount = userInput.nextDouble(); System.out.println("Enter Interest Amount"); interestAmount = userInput.nextDouble(); System.out.println("Enter Minimum Monthly Payment"); minimumMonthlyPayment = userInput.nextDouble(); //Calculate Input For Chart (Not Working) payment = minimumMonthlyPayment; monthlyInterest = (((interestAmount / 100) * remainingBalance / yearsOfPayment) / 12); principal = payment - monthlyInterest; remainingBalance = remainingBalance - principal; //Calculate Number Of Years For Payment yearsOfPayment = (((interestAmount / 100) * remainingBalance) + remainingBalance) / minimumMonthlyPayment; //Output System.out.printf("\n Year: %d/%.0f", yearCounter, yearsOfPayment); System.out.printf("\nMonth Payment Interest Principal Remaining Balance"); System.out.printf("\n%d %.2f %.2f %.2f %.2f", month[monthCounter], payment, monthlyInterest, principal, remainingBalance); //Increment Counters monthCounter++; if (month[monthCounter] == 12) { yearCounter++; //Reset monthCounter monthCounter = 0; } //Line Spacing System.out.printf("\n\n\n\n\n"); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload