|
You have $240 on hand and no credit. Can you buy the $25,000 Miata? A good answer might be:No. | |
Car Purchase as a ProgramAll you needed was money OR credit. Just one would do. Of course, if you had lots of money and plenty of credit you could certainly buy the car. Sometimes a program has to test if just one of the conditions have been met. Here is a program that does that with the car purchase problem:
if statement is asking a question with two parts:
Each one of these parts is a relational expression (just as with previous programs in this chapter.) A relational expression looks at two numbers and gives you true or false.if cash >= 25000 || credit >= 25000 ---------- ---------- cash part credit part | |
QUESTION 15:Say that you enter 56000 for cash and 0 for credit. What answer (true or false) does each of the parts give you? Click Here after you have answered the questioncash >= 25000 ________________ credit >= 25000 ________________ |