5.7 Class AutoPolicy Case Study: Strings in switch Statements

Strings can be used as controlling expressions in switch statements, and String literals can be used in case labels. To demonstrate that Strings can be used as controlling expressions in switch statements and that String literals can be used in case labels, we’ll implement an app that meets the following requirements:

You’ve been hired by an auto insurance company that serves these northeast states—Connecticut, Maine, Massachusetts, New Hampshire, New Jersey, New York, Pennsylvania, Rhode Island and Vermont. The company would like you to create a program that produces a report indicating for each of their auto insurance policies whether the policy is held in a state with “no-fault” ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.