+ 3
Java code problems
https://code.sololearn.com/cEEYRbnnBdCv/?ref=app It must output a price if you input correct model but it doesn't. Do you know where problem is? Don't forget to give me a questions if there is any.
5 Respostas
+ 3
Oleg Storm
The main problem with your code is that you are using '==' operator to compare the user input with carModel when you should be using '.equals()' function to compare them.
To quote GeeksforGeeks - "== checks if both objects point to the same memory location whereas .equals() evaluates to the comparison of values in the objects."
https://www.geeksforgeeks.org/difference-equals-method-java/
If you want your code to print the price of the car if the user entered the correct car model then you need to replace "System.out.println(car.CarModel(model));" with "System.out.println(car.Price());"
This should get back on track. Let me know either way.
+ 2
I really didn't know what this (==) means till now🤤, it was so helpful! Thanks a lot for your answer, ODLNT😄.
+ 1
hi
0
https://code.sololearn.com/cEEYRbnnBdCv/?ref=app
My ultimate thanks to you, guys😊
0
hi