# csc 200 hw4 selection and loops libraryFine Part3 solutions Solution

1. Library Fines
A local public library needs a program to calculate the overdue fines owed by its patrons. The library needs the clerk to enter the full name and age of the patron. The clerk also needs to enter the name and the number of days overdue for the item. (The library accounts for full days overdue and not partial days overdue.) The library wants the clerk to be presented with a menu from which the type of material overdue can be chosen. The menu should look as follows:
1. Book
2. Magazine
3. DVD

Books that are overdue are assessed a fine of 50 cents per day. Magazines are assessed a fine of 25 cents per day. DVDs are assessed a fine of \$1.50 a day. There is a maximum fine assessed of \$5.00. Senior Citizens (over the age of 70) do not pay fines. Juvenile patrons (ages 6 through 17) pay a maximum fine of \$1.00.

Once the fine has been calculated all information about the patron and the overdue material should be printed to the screen. Here is an example of the report that should be output:
Name Mickey Mouse
Age 22
Item Name Fantasia
Item Type DVD
Number of Days Overdue 2
Overdue Fine \$3.00

Each time the program is executed it calculates the fine for a single item. If the user enters invalid data, then a message must be presented on the screen specifying the invalid information and the calculation is aborted.

HINT – no loops can be used in this problem.
Also remember we do not know how to compare strings.

a) Rewrite this problem statement in your own words. Create a list of short bulleted phrases showing all details about this problem. This list should include both the explicitly defined and implied details in the problem statement. Consider what information the program needs to remember in order to meet the requirements of the problem statement. Consider what tasks need to be completed by the program in order to meet the requirements of the problem statement. (Hint – do you think this rewritten problem statement will be longer or shorter than the original problem statement?)

Print out this rewritten problem statement to turn in with this homework.

b) Run your program multiple times using the following information as input. After each run of the program save your entire console output screen to a text file as discussed in our labs.
• You have an overdue book titled Introduction to Java. This book is 5 days overdue.
• Mickey Mouse is 75 years old and has an overdue magazine titled Travel to Disney World. The magazine is 1 day overdue.
• Minnie Mouse is 30 years old and has an overdue magazine titled O Magazine. The magazine is 10 days overdue.
• Charlie Brown is 10 years old and has an overdue DVD titled Charlie Brown Christmas. The DVD is 2 days overdue.
• Goofy Dog is 50 years old and has an overdue DVD titled 101 Dalmations. The DVD is 2 days overdue.
• Snoopy Dog is 20 years old and has an overdue book titled Doghouse Repair. The book is 60 days overdue.

c) Print out a copy of your source code and your output text file to turn in with this homework.