600.108 Intro Programming Lab, Week 4, Fall 2017

Getting Started: If your partner from last week's lab is present, please sit and work together again this week. Check with the lab leaders if you forget who your partner was, or if you need a (different) partner for this week for some reason. Start in opposite driver/navigator roles from last week if possible. This will be the last week to work with your original partner!

Do the posted Blackboard poll (week 4 quiz). Your lab leaders will review the answers before you get started on this week's exercise.

Almost all our phases this week will be coding. However, you will start with some analysis to determine how many test cases are needed to really thoroughly check that a solution is fully correct. As was the case last week, at each step you should make sure that your code not only compiles, but is also checkstyle compliant, using our configuration file!

The Problem:

Suppose you need to determine how a course you might take applies towards your degree requirements. The input to the program must be a single line of input containing the 3 digit department code for your major, and the data for one course which includes the full course number, the number of credits, and a list of area designators that it fulfills, if any. A full course number is the department code (such as 600), then a '.', then the course code (such as 107). We won't bother with section numbers. Possible area designators are H, S, E, Q, N, W. [Note, this input data is similar to Part B of Homework 3, but not exactly the same.]

Assume you have the following degree requirements:

Using this information, your program must then output all the degree requirements that the course could be used to satisfy, including specifically whether it is an upper or lower level major course. If the course does not satisfy any of the first four category requirements, then say it counts as elective credit only. Three sample runs below are shown to give you an idea of how the processing proceeds.

SAMPLE #1
Enter major department code: 550
Enter course data (dpt.num credits HSEQNW): 600.226 3 EQ
Major code: 550
Department #: 600
Course #: 226
Credits: 3.0
Areas: EQ
Course can be counted as elective credit only.

SAMPLE #2
Enter major department code: 350
Enter course data (dpt.num credits HSEQNW): 350.410 3.5 HWS
Major code: 350
Department #: 250
Course #: 410
Credits: 3.5
Areas: HWS
Course can be counted towards your writing requirement.
Course can be counted towards your HS requirement.
Course can be counted towards your upper level major requirement.

SAMPLE #3
Enter major department code: 140
Enter course data (dpt.num credits HSEQNW): 110.109 4
Major code: 140
Department #: 110
Course #: 109
Credits: 4.0
Areas: 
Course can be counted towards your math requirement.

Step 1) ANALYSIS: Figure out minimally how many different test cases your will need in order to be really sure that your program works the way it is supposed to. Write down how many, and an explanation of the different kinds of tests that must be included. Share with a lab leader for approval before continuing.

--- Switch driver/nagivator roles ---

Step 2) CODING: In this phase you will get and parse the input data. (You may be able to reuse some techniques from Homework 3.) Prompt for and read the major code, then prompt for and read the course data. Remember that the user must be able to type all the course data on one line, but that doesn't mean you have to read it all at once. You could read one token (piece of information) at a time, using the most appropriate data type and matching Scanner method. Or you could read the entire line at once and then use String methods to break it into the various parts. Ultimately, the data must be stored into 4 separate variables: department, number, credits, areas. After they have been read and stored, print all five pieces of input information (including the major code), labelled, one per line. Compile and run your program several times to be sure it works. Also run the Checkstyle tool on it with our configuration file and make sure there are no issues. Resolve any problems, then compile and test your program again. Show it to a lab leader for approval to move on.

--- Switch driver/nagivator roles ---

Step 3) MORE CODING: Now that the data is in useful forms, we can start to check for requirements. Add statements to see if the course applies to the math credit requirement, the writing requirement, and the humanities/social science category. These are not mutually exclusive! A course could be all three, or none, or any combination. Print appropriate statements for each requirement that it satisfies. As before, make sure your solution is checkstyle compliant before moving on. [If you start to get cyclomatic complexity issues, try to resolve, but don't spend too much time on it.]

--- Switch driver/nagivator roles ---

Step 4) STILL MORE CODING: Next, if the course can be applied to the major, indicate whether it is upper or lower level credits. Lastly, figure out how to keep track of which requirements were met, so that if the course doesn't satisfy any of them, the program says that is an elective course. Make sure your code is still fully checkstyle compliant. Compile and run your program several times to be sure it works. Show to a lab leader for approval.

--- Switch driver/nagivator roles ---

Step 5) FINAL CODING: In this stage you will create some extensions to the original problem. There are two things you should work on:

Step 6) CLEAN-UP: Zip all the files together from today's lab and email to both students. Then each student must submit their work on Blackboard for the week, noting their partner's name and JHED login in the submission textbox. You must then delete your files off the lab computer and logout before leaving! Failure to do so constitutes an ethics violation.