600.108 Intro Programming Lab, Week 3

Start with the same partner as last week, but in opposite driver/navigator roles from last week. (See your lab leader if your partner is missing, or if you missed last week.) Remember that only the driver can write/type; the navigator's role is to oversee and make suggestions and corrections.

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.

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 are shown below to give you an idea.

SAMPLE #1
Enter major department code: 550
Enter course data (dpt.num credits HSEQNW): 600.226 3 EQ
This 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
This course can be counted towards your writing requirement.
This course can be counted towards your HS requirement.
This 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
This course can be counted towards your math requirement.
Almost all our phases this week will be coding.

Phase 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 your lab leader for approval before continuing.

--- Switch driver/nagivator roles ---

Phase 2) CODING: In this phase you will get and parse the input data. (This is the hardest part of the project most likely.) 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. Now using String methods to separate the course data into 4 parts, saving each into appropriate variables: department, number, credits, areas. Print all five pieces of information (including major code), labelled, one per line.

--- Switch driver/nagivator roles ---

Phase 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, and if it applies to the writing requirement. They are not mutually exclusive. Print appropriate statements for each.

--- Switch driver/nagivator roles ---

Phase 4) STILL MORE CODING: Now check on humanities/social science, and also whether or not the course could be used for the major. If it is a major course, indicate whether it is upper or lower level credits.

--- Switch driver/nagivator roles ---

Phase 5) FINAL CODING: Lastly, figure out how to keep track of which requirements were met, so that if the course doesn't satisfy any of them, it says that is an elective course. If you have extra time, add input validation: Major codes, department codes and course numbers must be between 1 and 999. Credits must be a multiple of 5 between 1 and 4.5 inclusive. Area designators can only be the letters H,S,E,Q,N,W - you'll need a loop for this last challenge.

Remember to delete your files off the lab computer and logout when done!