Welcome back. I hope you had fun trying to solve the problem.
I'm sure you did great.
As you noticed in the workspace I created the challenge which just created an empty shell
for the problem.
And I've also got the challenge solution which has my solution to the problem.
Okay. So let's start looking at the code here.
We know what we had to solve.
So let's look at some of these really simple statements first.
And I'll mark this up just so it's easier for you to follow.
So in this case, I'm simply outputting welcome
then I've defined a variable here which is going to hold small rooms.
And I've initialized to 0, that's the best practice. I'm prompting the user.
And I'm asking them to put in the number of small rooms they want cleaned.
I'm doing exactly the same thing here except we're doing large rooms.
And now we've got to define 2 declared constants right.
We're going to declare one is the price for a small room
and one is the price for a large room, 25 and 35, respectively.
We've got our sales tax declared constant here, and we've got our estimate
expiry constant.
So far so good. It's exactly the same as we did before.
The only thing is I'm adding the large rooms.
Okay. So let me clear this and I'll scroll up just a little bit
and let's take a look at some of the calculations.
Here are some of the output statements,
and you can see here I'm as I'm outputting the number of small rooms which is just
whatever the user typed in and the number of large rooms which is whatever they typed in.
The price per small room and the price per large room right here,
those are our declared constants which I'm outputting. Now the cost.
The calculation is really simple it's the cost of the small rooms plus the cost of the large rooms,
and we calculate each one by
price per small room times the number of small rooms
plus and there's my plus sign. Remember you can split these across lines so you can
line up the insertion operators like that it makes them nice and easy to read.
So in this case, I'm just calculating the cost for the small rooms, and I'm adding
the cost of the large rooms to it.
Same thing with tax. I'm calculating the cost again.
And I'm multiplying the whole thing by sales tax.
Notice that I've got those parentheses here because what I want to do is
I want to calculate the whole cost
and then multiply that by the sales tax. Otherwise,
I won't get the correct answer.
Got to make sure the whole thing is here.
So this becomes all the small costs plus all the large costs.
Okay. Then finally, the total estimate just takes the cost
and adds the sales tax to it. That's it.
The estimate is valid for 30 days and there's my program.
So you can see that
my formatting is probably going to be a little bit different from your formatting,
and mine might be a little bit more readable.
But you may not have split things across lines like I did.
It's real good practice to split these across lines that way you can
really see what's going on, and it's much, much easier to follow.
Okay. Well, I hope you enjoyed the challenge, and I hope you did well.
Remember, there's a lot of duplicated code here that we're going to clean up as the course progresses.
And this program -- we'll actually modify this program a little bit later
on when we use functions.
Okay, so that's it for the challenge.