00:01
In this video, we will rewrite compute change .java such that the user enters an input whose last two digits represent the sense in order to fix the possible loss of accuracy when converting a double to an integer value.
00:13
So i've outlined the class as well as the main method within it.
00:16
I've also imported java .util .scanters, we can go ahead into our main method and create a new scanner object using the standard input stream.
00:25
We can call this input.
00:28
To do this, we'll pass the predefined object, system .n .n, as an argument.
00:36
Next thing we want to do is use system .out .out, print, ln to prompt the user to enter their monetary input.
00:44
Next, we will create an integer called amount and set this equal to input.
00:52
Next .int, a method that this stores the input as an integer.
00:59
Next, we'll want to set another integer value called remaining and initialize it as amount in case we need to access our original amount, as the remaining variable will be changing during our subsequent calculations.
01:20
So after this, we'll want to find the number of whole dollars in our amount.
01:32
So we can do in dollars.
01:35
It's going to equal remaining integer divide by 100, 400 cents.
01:42
So we can take our remaining and set it equal to remaining modulus 100 cents...