CPSC-115 Fall 2008
Lab 4
September 23/24, 2008
Professor Heidi Ellis

Be sure that you hand in the printouts of your work before leaving!!!

Objective:

Pre-lab: The prelab for Lab 4 is to create a flowchart algorithm for both programs. Hand in both flowcharts at the beginning of class.
The domain of this lab is an online video rental system where customers rent a number of movies per month. The programs described below involve calculating the monthly rental charge for a customer for a single month. The first program calculates the charge based on a flat rate for regular videos and recent releases while in the second program the charge is calculated based on which of three different rate programs a customer belongs to.
Pair Programming:
  1. Locate your partner and introduce yourself:
  2. Tuesday Lab   Wednesday Lab
    Kristen AndersonJake Elder     Chelsea Bainbridge-DonnerGreg Vaughan
    Zain KahnJeff Young     Catherine DoyleJin Feng Liu
    Nick Dragu      Jesse VazquezRyan Ersland
           Corazon IrizarryJohn Wilstrman
  3. Select one person to start as "driver". This person will type at the keyboard for the first 20 mintues.
  4. Proceed through the process of completing the lab as described below. Be very careful to ensure that every item for both programs is completed.
  5. Swap pairs every 20 minutes.
  6. When you are done, be sure to email a copy of the code to the person whose account you are not working in. In other words, make sure that both partners have a copy of the code.

Program 1: Video Rental Flat Rate

This program calculates the charge for a customer of the online video service using a flat rate of $2.00 per regular (non-recent release) video rented and $3.00 per recent release rented. The program must allow the user to enter the following information:
  1. customer name
  2. customer id
  3. number of regular videos rented this month
  4. number of recent releases rented this month
Your program must calculate the rental charge. Premium customers are those who listen to 20 videos (of either kind) or more a month. Premium customers receive a 10% discount on their charge. Premium customers are designated by having a 'P' as the first character in their id.

In addition, we want to identify additional potential premium members. Therefore, if a customer has rented over 20 vidoes and is not a premium member, then your program should recommend that they become a premium member and tell the user how much they would have saved had they been a premium member.

Lastly, if the customer has rented more recent release videos than regular videos, your program should suggest that the customer sign up for automatic notifications of recent releases.

The text below shows the results of three different test runs. Your program should provide similar output.

Case 1: Non-premium member with less than 20 videos:

Welcome to Rockin' Rental!
Enter customer name: Jan
Enter customer ID: Z9090
Enter number of regular (non-recent releases) videos rented: 6
Enter number of recent release videos rented: 3

Customer name: Jan
Customer ID: Z9090
Number of regular videos rented: 6
Number of recent releases rented: 3
Charge: $21.0
Case 2: Premium member:
Welcome to Rockin' Rental!
Enter customer name: Phil
Enter customer ID: P5697
Enter number of regular (non-recent releases) videos rented: 5
Enter number of recent release videos rented: 3

Customer name: Phil
Customer ID: P5697
Number of regular videos rented: 5
Number of recent releases rented: 3
Charge: $17.1
Case 3: Non premium member who rented over 20 videos and rented more recent releases than regular videos:
Welcome to Rockin' Rental!
Enter customer name: Fran
Enter customer ID: Q7865
Enter number of regular (non-recent releases) videos rented: 10
Enter number of recent release videos rented: 20

You have rented over 20.0 videos this month and you are not a premium  member.
You should consider becoming a  premium member. You would save $8.0

You appear to enjoy recent releases. Please consider signing up for automatic notification of recent releases.

Customer name: Fran
Customer ID: Q7865
Number of regular videos rented: 10
Number of recent releases rented: 20
Charge: $80.0

Hints:

Your code should have good programming style and follow all Java conventions. Don't forget to use constants where appropriate.

Program 2: Video Rental Three Rental Plans

This program calculates the charge for a customer of the video music service using three different rental plans. Do not modify the flat rate video class as you may want to use that to study from. Instead, make a copy of that class and modify the copy. The three rental plans are:
  1. $20/month for 10 videos and each additional regular video, regular or recent release is $4.00 per video.
  2. $30/month for 15 videos and each additional regular video, regular or recent release is $3.00 per video.
  3. $40/month for 20 videos and each additional regular video, regular or recent release is $2.00 per video.
The program must allow the user to enter:
  1. customer name
  2. customer id
  3. number of regular videos rented this month
  4. number of recent releases rented this month
  5. rate plan
Your program must calculate the rental charge according to the rate plans listed above. You must use a switch statement to calculate the charge based on the rate plan. The premium members have the same discounts as in your first class, and you should still suggest to non-premium customers who rent more than 20 videos that they become premium members. You should also suggest to customers who rent more recent releases than regular videos that they might like to sign up for automatic notifications of recent releases. The text below shows the results of four different test runs. Your program should provide similar output.

Case 1: Non-premium customer on plan B. Note that the rate plan may be entered in either upper or lower case.

Welcome to Rockin' Rental!
Enter customer name: Barb
Enter customer ID: B6473
Enter rate plan: B
Enter number of regular (non-recent releases) videos rented: 8
Enter number of recent release videos rented: 2

Customer name: Barb
Customer ID: B6473
Number of regular videos rented: 8
Number of recent releases rented: 2
Charge: $30.0
Case 2: Premium member on plan C who rented 10 videos over the limit.
Welcome to Rockin' Rental!
Enter customer name: Pammy
Enter customer ID: P8765
Enter rate plan: c
Enter number of regular (non-recent releases) videos rented: 20
Enter number of recent release videos rented: 20

Customer name: Pammy
Customer ID: P8765
Number of regular videos rented: 20
Number of recent releases rented: 20
Charge: $72.0
Case 3: Non-premium customer with incorrect rate plan:
Welcome to Rockin' Rental!
Enter customer name: Sam
Enter customer ID: Y4323
Enter rate plan: F
Enter number of regular (non-recent releases) videos rented: 10
Enter number of recent release videos rented: 2
Invalid plan.

Customer name: Sam
Customer ID: Y4323
Number of regular videos rented: 10
Number of recent releases rented: 2
Charge: $0.0
Case 4: Non-premium member on rate plan A who should be a premium member and who should consider signing up for automatic notifications of recent releases.
Welcome to Rockin' Rental!
Enter customer name: Millie
Enter customer ID: M2365
Enter rate plan: A
Enter number of regular (non-recent releases) videos rented: 20
Enter number of recent release videos rented: 30

You have rented over 20.0 videos this month and you are not a premium  member.
You should consider becoming a  premium member. You would save $18.0

You appear to enjoy recent releases. Please consider signing up for automatic notification of recent releases.

Customer name: Millie
Customer ID: M2365
Number of regular videos rented: 20
Number of recent releases rented: 30
Charge: $180.0
Your code should have good programming style and follow all Java conventions. Don't forget to use constants where appropriate.

You're done!! Don't forget to log out and hand in your printouts to the professor before you leave!!