Lab 5: Decisions

Purpose

The purpose of this in-lab is to introduce you to the concept of making decisions in Java using the if statement.

Partners

You are encouraged to work with one other partner on this assignment.

Preliminaries

Create a BlueJ project named lab5 on your lab computer. Place the following files into this project:

Assignment

Train travelers in Germany can buy a one year discount card for the train system called a BahnCard. There are three types of BahnCards: a BahnCard 25 (provides the rider with a 25% discount), a BahnCard 50 (provides the rider with a 50% discount), and a BahnCard 100 (provides the rider with a 100% discount). In Germany, one can travel first class or second class on the train system.

In this assignment, you are going to calculate how much a BahnCard costs to buy, using the following rules.

Note: do not modify the TestProgram.java file.

Submission

Before your lab section finishes, e-mail your lab TA the BahnCard.java file in an e-mail with the following subject line: CS 160, Lab 5, your name, your partner's name.

Grading - 40 points possible

To receive credit for this assignment, your lab TA must receive an e-mail (with a timestamp before your lab section ends) from you with the file BahnCard.java attached to it. Do not worry if you are not finished - send what you have because partial credit can be earned.

Helpful Hint

There are three methods in the BahnCard class that you must modify: bahnCard25Price, bahnCard50Price and bahnCard100Price. Do the easiest method first, the second easiest method second and the most difficult method last.

Before Lab Ends

Once you have e-mailed your lab TA the BahnCard.java file, please delete the Lab5 directory that you created and empty the recycle bin on your desktop. Thanks.

Valid XHTML 1.0!