You have $240 on hand and no credit. Can you buy the $25,000 Miata?

Answer:

No.

Car Purchase as a Program

All you need is money OR credit. Just one will do. Of course, if you have enough money and have enough credit you can certainly buy the car.

Sometimes meeting just one condition is enough. Here is a QBasic program that does that with the car purchase problem:

' Car purchase tester
'
PRINT "Enter cash"
INPUT CASH
PRINT "Enter credit"
INPUT CREDIT
IF  CASH >= 25000 OR CREDIT >= 25000 THEN
  PRINT "Car Purchase Approved!!"
ELSE
  PRINT "purchase rejected"
END IF
'
END

The IF statement asks a question with two parts:

IF CASH >= 25000 OR CREDIT >= 25000 THEN
   ----------         ------------
   cash part           credit part

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.

QUESTION 17:

Say that you enter 56000 for CASH and 0 for CREDIT. What answer (true or false) does each of the parts give you?

               
CASH   >= 25000  ________________

CREDIT >= 25000  ________________