Learn Java - Beginner 13 - Number Format

preview_player
Показать описание

In this video, I show you how to format numbers to represent money and percentages.
Рекомендации по теме
Комментарии
Автор

@ Bryan S. I think the point is so that if you were to build your own program the initialValue would more than likely be from user input. And then the number collected would be then converted to dollars or currency.

futureitshere
Автор

I have a question.
When you were writing out the code for the final print, why did you have to reference the variables *initialValue*, *interestRate*, and *total* with the syntax that you used?

From what I saw, they were all declared previously as variables.

So, I guess what I'm not understanding is why that code was written as *money.format(interestRate)* instead of just *interestRate*.

Wouldn't it have been the same if you had just typed in the characters ($, %, etc) as a part of the strings themselves? Like for example: "You will have a initial amount of $" + initialValue +... it goes on.

Do you recommend a certain way of doing this?

Thanks for your time,

- Bryan

THAT.RANDOM.GUY_
welcome to shbcf.ru