RU beehive logo ITEC dept promo banner
ITEC 120
2009spring
ibarland
nokie
jmdymacek

homeinfolectslabsexamshws
textbooktutor/PIsjava.lang docsjava.util docs

lab08a
booleans: and and or

Recall that && and || each take two booleans, and return a boolean. For example:

// These evaluate to either true or false, depending
// on what value the variables have:

(ptsPossible == 0) || (ptsEarned / ptsPossible > 0.85)

(numTickets <= seatsOnPlane) || (seatsOnPlane > 0)

Discussion question:

// SOME INCORRECT CODE:

String waterForm( double temp ) {
  if (temp < 32 && > 212) {
    return "not liquid";
    }
  else {
    return "liquid";
    }
  }


Your task: P5.12 from the textbook: Revise BankAccount so that:

Here is the BankAccountTester.java and BankAccount.java we wrote in class.

First add test cases which include:

Of course, after each of these calls, you should verify that the balance is unchanged. Then modify the code. When verifying that a withdrawal amount is valid, use one of && or || (instead of using nested if-elses).


1If you also want to print a warning message to System.err, that would be eminently reasonable, but not required.      

homeinfolectslabsexamshws
textbooktutor/PIsjava.lang docsjava.util docs


©2009, Ian Barland, Radford University
Last modified 2009.Mar.17 (Tue)
Please mail any suggestions
(incl. typos, broken links)
to iba�rlandrad�ford.edu
Powered by PLT Scheme