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....🤘❤️
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.
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.
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?
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?
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?
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
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.
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.
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) );
@@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!
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....🤘❤️
once again best tutorial
Thank you so much, great tutorial. Keep going!
Thank you so much for this video you have saved my day!
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.
In Eclipse, ctrl + shift + O will organize imports
@@CodingWithJohn Thanks mate. 💯
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 .
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.
So helpful !! Thank you :D
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?
Thank you so much sir 😍
Very nice video. Thank you.
Could you do it as a GUI ?
Thank you very much 🙂
you are the best ❤️
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?
Love this video!!! Im trying to add Property tax & home owner insurance calculating code but having hard time ! Can you please help ?
Thanks : )
I’m having trouble with json files and android. I would love to see you do a video on json
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?
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
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.
@@CodingWithJohn thanks I think telling me the information is more important
How would we calculate the total interest?
hmm my monthly payment ended up being -96666.6664etc monthly. Do you have an idea why that would be?
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.
@@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);
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)
);
@@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!
how to see the principal ammount?
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.
i did not see principal ammount?
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).