00:01
In this video, we will be rewriting compute change program to incorporate input and output dialogues.
00:06
Instead of using the scanner class to take input from the user, i've already created our class as well as the main method within it.
00:14
I've also already imported javax .swing.
00:20
This is a lightweight gui widget toolkit for java, which we'll be using to create a pop -up box that will prompt the user for input.
00:31
Go into the main method and create a j -option pain class to pop up a standard dialog box.
00:44
So we can declare this input as a string.
00:54
The j -option -pain class has a method show input dialog.
01:03
So this will allow the user to enter an amount.
01:14
With this message telling us, telling them to enter an amount as an integer, i .e., after this, we'll want to convert our string to an integer, since the input dialog takes string, we can say int amount equals integer parse int, or input.
02:28
Like we did previously, we'll keep our integer amount the original amount and then create another variable change while we're doing calculations called remaining and then initialize that to the amount.
02:45
We're going to go ahead and do the same thing we did in question 24 and create an integer number of dollars, which is going to be the remaining integer divide by 100, remaining mod equals 100, and we're going to go ahead and do this for our quarters.
03:20
So integer dividing by 25, remaining mod equals 25.
03:29
Now for dimes, remaining mod equals 10, and then in nichols equals remaining integer divide by 5, and remaining not equals 5.
04:03
And lastly, we can set our pennies equal to the remaining sentence.
04:11
So now that we have all of our variables, we can display our results...