Create a Java Mortgage Payment Calculator - Full Tutorial

Поделиться
HTML-код
  • Опубликовано: 19 ноя 2024

Комментарии • 33

  • @shreyashkar9407
    @shreyashkar9407 3 года назад +4

    Thank you so much sir for this very easy to understand video not only I understood the code but at the same time I now know how to find the mortgage on paper 😂......keep up the good work and keep these kind of small projects coming in....🤘❤️

  • @designwithgeet7895
    @designwithgeet7895 3 года назад +1

    once again best tutorial

  • @dolgoonamartaivan7268
    @dolgoonamartaivan7268 3 года назад +2

    Thank you so much, great tutorial. Keep going!

  • @kwerksickle
    @kwerksickle 3 года назад

    Thank you so much for this video you have saved my day!

  • @lesegoleso4918
    @lesegoleso4918 2 года назад +1

    This is the 1st video I watch from you and I love this channel already 😂🖤
    What shortcut did you use to get the Import Scanner part? I always type it out.

    • @CodingWithJohn
      @CodingWithJohn  2 года назад +1

      In Eclipse, ctrl + shift + O will organize imports

    • @lesegoleso4918
      @lesegoleso4918 2 года назад

      @@CodingWithJohn Thanks mate. 💯

  • @mikelawry07
    @mikelawry07 3 года назад +1

    Sir you are the Mafia in Java. I don’t want to miss any tutorial of your . Please give me the link of your course, I don’t mind to pay .

    • @CodingWithJohn
      @CodingWithJohn  3 года назад

      I'm thrilled you enjoy the videos, thanks so much for watching!
      The link to the course is in each video description, but here it is again: codingwithjohn.thinkific.com/courses/java-for-beginners
      There's a listing there of all the lessons and what they cover so you're not surprised by what it covers, and even a few free preview lessons. I'll be adding more to that course in the future as well, and anyone who gets it will have access to all current and future content forever.

  • @andymorales5718
    @andymorales5718 3 года назад +1

    So helpful !! Thank you :D

  • @awesomebearaudiobooks
    @awesomebearaudiobooks Год назад +1

    I wrote the code exactly as you did and I get this error after entering the annual interest rate:
    Enter the annual interest rage:
    .04
    Exception in thread "main" java.util.InputMismatchException
    at java.base/java.util.Scanner.throwFor(Scanner.java:939)
    at java.base/java.util.Scanner.next(Scanner.java:1594)
    at java.base/java.util.Scanner.nextFloat(Scanner.java:2496)
    at javalearning/mortgagecalculator.Main.main(Main.java:23)
    My scanner is written just like yours:
    System.out.println("Enter the annual interest rage:");
    float annualInterestRate = scanner.nextFloat();
    Why is this so? The program itself works if I divide by 100:
    System.out.println("Enter the annual interest rage:");
    float annualInterestRate = scanner.nextFloat() / 100;
    But I DO want to be able to work with amounts like .04, so how can I fix this?

  • @phatttin6753
    @phatttin6753 2 года назад

    Thank you so much sir 😍

  • @thomas_m3092
    @thomas_m3092 2 года назад +1

    Very nice video. Thank you.
    Could you do it as a GUI ?

  • @stuckintha90s
    @stuckintha90s 2 года назад

    Thank you very much 🙂

  • @kunalkheeva
    @kunalkheeva 2 года назад

    you are the best ❤️

  • @tarviky
    @tarviky Месяц назад

    Is Scanner only used for the Console preview purposes as far as I understand? So in case if I want to use this code on my actual website and not in the console I have to delete all of the lines with the scanner code right?

  • @nahomegirma3596
    @nahomegirma3596 2 года назад

    Love this video!!! Im trying to add Property tax & home owner insurance calculating code but having hard time ! Can you please help ?

  • @bigtimetechnology3249
    @bigtimetechnology3249 2 года назад

    Thanks : )

  • @wristdisabledwriter2893
    @wristdisabledwriter2893 3 года назад +1

    I’m having trouble with json files and android. I would love to see you do a video on json

    • @CodingWithJohn
      @CodingWithJohn  3 года назад

      I haven't done a ton with Android applications, but I work with JSON every day. Is it mostly just serializing objects into JSON, and deserializing JSON strings back into objects? Or is there some other aspect?

    • @wristdisabledwriter2893
      @wristdisabledwriter2893 3 года назад

      I’m trying to make a quiz app and unfortunately my teacher insisted on json files to get the questions and answers. I don’t know what serialize means. Can you tell me that too

    • @CodingWithJohn
      @CodingWithJohn  3 года назад +1

      Serializing is when you take a java object and translate it into some format to be saved outside of the program, typically into a file or database as some type of string representation. So for example you can serialize an object into JSON in a file. Deserializing is the other way, where you take some stored info, such as from a DB or file, and make an object out of it.
      I'm not sure I'll be able to get to making a video about all that and it may not apply well to your specific situation anyway, but we use a library called Jackson at work to do our JSON serialization and deserialization. It may not help at all with your project unfortunately, but it's what I'm familiar with.

    • @wristdisabledwriter2893
      @wristdisabledwriter2893 3 года назад

      @@CodingWithJohn thanks I think telling me the information is more important

  • @Luna-tl9xh
    @Luna-tl9xh 3 года назад

    How would we calculate the total interest?

  • @Ehrenization
    @Ehrenization 3 года назад +1

    hmm my monthly payment ended up being -96666.6664etc monthly. Do you have an idea why that would be?

    • @CodingWithJohn
      @CodingWithJohn  3 года назад +1

      Hmm well I'd certainly love to have a payment where the bank pays me almost $100,000 per month... But yeah, something has to be wrong. If you want you can paste in your code, and what numbers you're entering, and I (or your fellow viewers) can have a look and see if we can find out what might not be right.

    • @Ehrenization
      @Ehrenization 3 года назад

      ​@@CodingWithJohn yeah for sure!
      package com.ehrenlearnsjava;
      import java.sql.SQLOutput;
      import java.util.Scanner;
      public class Main {
      private static final int MONTHS_IN_A_YEAR = 12;
      public static void main(String[] args) {
      Scanner scanner = new Scanner(System.in);
      System.out.println("Enter the principal amount:");
      double principal = scanner.nextDouble();
      System.out.println("enter the annual interest rate:");
      float annualInterestRate = scanner.nextFloat();
      System.out.println("enter the term in years");
      int termInYears = scanner.nextInt();
      float monthlyInterestRate = annualInterestRate / MONTHS_IN_A_YEAR;
      int numberOfPayments = termInYears * MONTHS_IN_A_YEAR;
      double monthlyPayment = principal * (
      monthlyInterestRate * (Math.pow(1 + monthlyInterestRate, numberOfPayments)) /
      (Math.pow(1 + monthlyInterestRate, numberOfPayments)) - 1);
      System.out.println("Monthly payment: " + monthlyPayment);

    • @CodingWithJohn
      @CodingWithJohn  3 года назад +5

      I figured out what's wrong with yours - it looks like your parentheses are off in your payment calculation. The way the parentheses are arranged in this program is very important, and if they're not just right, the whole calculation can be thrown off.
      If you replace your calculation with this, it should work great:
      double monthlyPayment = principal * (
      (monthlyInterestRate * (Math.pow(1 + monthlyInterestRate, numberOfPayments))) /
      ((Math.pow(1 + monthlyInterestRate, numberOfPayments)) - 1)
      );

    • @Ehrenization
      @Ehrenization 3 года назад +4

      @@CodingWithJohn Wow thank you! I just made the adjustments and it worked, now I know to keep a more watchful eye on those perentheses. I really appreciate the time you put in to answering my question!

  • @nathanielbriones6997
    @nathanielbriones6997 3 года назад

    how to see the principal ammount?

    • @CodingWithJohn
      @CodingWithJohn  3 года назад

      The principal amount is one of the inputs the user puts in. You can't calculate the mortgage payment without having the principal amount already.

  • @nathanielbriones6997
    @nathanielbriones6997 3 года назад

    i did not see principal ammount?

    • @CodingWithJohn
      @CodingWithJohn  3 года назад

      We collect it from the user on line 13 in the program, then use it in the calculation on line 24/25 (depending on where you are in the video).