go to previous page   go to home page   hear noise   go to next page

Answer:

Yes.

Car Buying Program

The sales manager of the car lot will let you buy the car if:

Say that "outstanding debts" means debts more than $1,000. Here is a program that makes the car buying decision:

// Sports Car Purchase
//    New $25,000 red Miata sports car.
//    You need cash or credit with no debts .
//
import java.util.Scanner;
class HotWheels2
{
  public static void main (String[] args)
  { 
    Scanner scan = new Scanner( System.in );
 
    String inData;
    int    cash, credit, debt ; 

    // get the cash
    System.out.println("How much cash?");
    cash    = scan.nextInt();

    // get the credit line
    System.out.println("How much credit do you have?");
    credit   = scan.nextInt(); 

    // determine the debts
    System.out.println("How much much do you owe?");
    debt     = scan.nextInt();

    // check that at least one qualification is met
    if ( cash >= 25000  ||  ( credit >= 25000 && debt < 1000 ) )
      System.out.println("Enough to buy this car!" );
    else
      System.out.println("Have you considered a Yugo?" );

  }
}

The boolean expression of the if statement correctly implements the car buying rules. The expression includes both && and ||.

QUESTION 13:

You have zero dollars, $26,000 in credit and $500 in debts. Do you get the car?