600.107 Introduction to Programming in Java
Homework #4 - due 11:30pm on Tuesday 10/3

Overview

The primary goal of this assignment is to get practice writing and testing decision statements in Java. You'll also get some (more) practice working with computations and different variable types. You'll need to download our posted HW4start.zip file to get the file necessary to do part A of this assignment.

Deliverables: Your final submission on blackboard must be a single zip file called HW4-jhedLogin.zip, substituting your actual JHED/Blackboard login as the second part of the file name. It must contain the following files from both parts of the assignment: Choices.java, Hw4b.java. Remember that you can submit multiple times; just make sure that your final submission includes all parts! Also remember that your Java code must compile (no errors) in order to receive any credit for it, and it must be checkstyle compliant (with our configuration file) except where noted below for full credit.


Part A: Decisions & Tests

We have provided a file called Choices.java for you. It has several methods that are missing decision statements in order to do their job. It also only has a few tests for each method. You have two tasks: 1) write the java code necessary to make each method do its job correctly and 2) add many more tests to main so that your methods are really thoroughly tested with all parameter situations they might need to handle.

This program must be checkstyle compliant with the exception of overly long lines in main - that is the only violation allowed. You are likely to get a cyclomatic complexity issue for the rock-paper-scissors method. This is hard to eliminate for a situation like this with many different cases. The idea is to combine cases as much as possible to reduce complexity. If you can't reduce it below the limit, don't sweat it too much. Next week we'll learn better how to write methods, which is a good way to reduce complexity also.

Part B: Wireless Bill

Write a program (from scratch!) that will calculate and print an itemized wireless phone bill. Call your program and file "Hw4b.java". Here is how charges are computed: the base cost is $32.99 for an individual and $53.75 for a family plan. If it is a family plan, there is an additional cost of $12 per line after the first member. "JHU" and "Wireless" employees get a 10% discount off the total before tax is calculated. There is a 6% tax charge for all bills. The program should handle company names correctly regardless of capitalization (ie, ignoring case).

Here are two sample runs, showing the user input in bold fonts. The format of your input prompts and output must be exactly the same as given in the sample runs below, including capitalization and spacing. The dollar amounts for the output must have exactly two digits after the decimal point. Note that the input is conditioned on the plan type. Specifically, don't prompt for the family size if an individual plan is selected.

    SAMPLE #1
    Enter 'I' for individual or 'F' for family plan: F
    Enter total number of family members: 5
    Where do you work? Home Depot

    Base charge: $53.75
    Addition line charge(s): $48.00
    Discount: $0.00
    Subtotal: $101.75
    Tax: $6.11
    Total Due: $107.86

    
    SAMPLE #2
    Enter 'I' for individual or 'F' for family plan: I
    Where do you work? Wireless

    Base charge: $32.99
    Addition line charge(s): $0.00
    Discount: $3.30
    Subtotal: $29.69
    Tax: $1.78
    Total Due: $31.47
    

Although we are not requiring you to submit extra test cases or pseudocode, you should always do those steps of the programming process before sitting down to write java code! Feel free to include them as a plain text or pdf document in your zipped assignment submission.

You are not required to do error checking on the input. In other words, assume that the user gives you expected answers to the input prompts. However, as an extra challenge, include loops that will keep prompting to make sure that the plan type is an 'I' or 'F' and that the number of family members is greater than 1 where relevant.


General assignment requirements, style and submission details: