Boolean Expressions

7. Car Rental Problem


Yes. It is always good to test programs with values that are right at the limit.

Car Rental Problem

A car rental agency wants a program to determine who can rent a car. The rules are:

      • A renter must be 21 years old or older.
      • A renter must have a credit card with $10,000 or more of credit.

The program looks something like the cookie program:

// Rental Car Checker
import java.util.Scanner;
public class RenterChecker
public static void main (String[] args)
// Declare a Scanner and two integer variables
Scanner scan = new Scanner( );
int age, credit; // get the age of the renter
System.out.println("How old are you?");
age = scan.nextInt() ; // get the credit line
System.out.println("How much credit do you have?");
credit = scan.nextInt() ; // check that both qualifications are met

if ( && )
System.out.println("Enough to rent this car!" );
System.out.println("Have you considered a bicycle?" );

Question 7:

Complete the program by filling in the blanks.

Consider carefully what relational operators to use.