Onwards, the part three in part to out the code for Case A. And here's what we have so far.
The user chooses to buy a car and then we check if they can afford it, if they have insurance, have
a license and a good credit score.
And if everything checks that, we let them buy a car.
In this lesson, we're going to add the logic for Case B, selling a car.
Into the job, a dealership will purchase anyone's car under two conditions, the selling price is lower
than the car's value and the selling price is lower than 30000 dollars.
So the first thing I'm going to do is delete this print statement and then the program is going to ask
the client for the value of their car.
So print.
What is your car valued at?
And because sense aren't relevant in buying or selling cars, you're going to store the value as a whole
number int value is equal to Scannon extends.
Now we're going to ask the user how much they're selling the car for, what is your selling price?
And we're going to store the selling price as a whole, no.
Scandal next it.
Now the dealership will buy the car under one condition, the price has to be lower than the car's value
and lower than 30000.
I hope this made you think of the end operator.
So if the value of the car is greater than the price it's being sold at.
And if the price is less than 30000.
Then the dealership will buy the car, that is, we're going to print.
We will buy your car.
A pleasure doing business with you.
Otherwise.
Sorry, we're not interested.
OK, I think we're ready to run our code.
We're going to select option B.
What is your car valued at, let's say 25000 selling price.
Let's sell it at 20 thousand and the dealership buys my car and that's all.
Now you have an outlet.
You buy or sell a car for selling a car.
You started by picking up two integer values.
And the values that you enter to make both comparisons, true, so Java and the code inside the statement
and the dealership bought your car.
In any case, we should add some blank lines to make the output look better.
So starting from what is your car valued at, at a blank line at the beginning of each print line statement?
So again.
Slash and.
And another.
We're in a rerun the code.
And we're going to choose option B.
Twenty four thousand selling price of, say, 20000.
And the output looks really good.
There you have it, you built an interactive dealership application.
In this lesson, you added the logic for selling a car if you made it this far.
I want to congratulate you.
Now, you have full control over how your code runs using.
You let the user choose from a list of options and using a false you controlled how the dealership reacted
based on the user input.
I think it's time for your big challenge.