Before we start, did you try solving the workbook yourself?
If not, please click the link in the resources folder and follow the instructions for this workbook.
This video will present the solution to workbook 2.4.
From Vsco We don't need to launch the exact folder that contains my Java file.
In this case, the folder is called Workbook 2.4.
All right.
Task number one is to convert each decimal to a whole number before printing it as part of a much larger
string.
So let's start off by breaking up this string such that we can embed values inside of it.
Here we will embed the sales value.
Here, we can embed the profit value.
Refunds.
And here we can concatenate the shipping variable.
Okay, Let's go ahead and run it.
New terminal Java.
See, we will compile the code inside of meeting Java and then we can run the compiled code as follows.
And this looks pretty ugly because in the thousands of dollars, do we really care about sense?
Before merging each decimal value into a surrounding string.
We need to convert that value to an integer.
Like so.
INT means hole number.
So by type casting the decimal to an int, all the decimals are going to get cut off and after the value
has been type casted to end, it is then merged as part of a larger string.
So let's go ahead and run our code.
And this looks beautiful.