600.107 Introduction to Programming in Java
Homework #3 - Due by 11:30pm on Wednesday, 9/27

Overview

The goals of this assignment are to get familiar with the Scanner and String classes for input and text manipulation. It will also provide pseudocode practice working with nested control structures (decisions and loops) as preparation for the next few assignments. You'll need to download our posted HW3start.zip file to get the files necessary to do this assignment.

Deliverables: Your final submission on blackboard must be a single zip file called HW3.zip that contains the following files from all parts of the assignment: Remember that you can submit multiple times on Blackboard, but that we only grade the last one. Therefore, make sure that your final submission includes all parts!


Part A: Sentence Twist?

Write a program that will get an entire line of input that should be a properly formed sentence. Rearrange the sentence into a question by moving the first two words to the end after a comma, and followed by a question mark. Fix the capitalization also so that the original first word starts with a lower case letter and the new first word starts with a capital letter. Here are two sample runs:

  input: The dog ran through the gate and down the street.
  output: Ran through the gate and down the street, the dog?

  input: My coat was too heavy for this warm day!
  output: Was too heavy for this warm day, my coat?

You can assume that any input sentence will have at least 3 words in it, and end with some type of punctuation mark. Name your program Hw3a.java and make sure it is fully checkstyle compliant.

Part B: Getting Input

Often we have programs that get several lines of input, with the data on each line of varying data types. For this part of the assignment, you'll be adding code to a starter program (Hw3bStart.java -> rename as Hw3b.java) to get input for processing a bunch of course data. The primary input to the program will be lines of course data, in this order and format:

    3.0 601.107 Intro Programming in JAVA (EQ)
    1 601.108 Intro Programming Lab (e)
    4.0 110.109 Calc something (q)
    3 250.999 something else entirely (wqn)
    

Note that you can't assume the area designators will be all upper case. Your job is to write the missing pieces of code based on the comments throughout the starter file, making sure you don't change any of the provided code as indicated. Your resulting code should be checkstyle compliant, with the exception of the TODO comment issues.

Part C: Football Scores Pseudocode

Suppose that you have set of football teams, their opponents, and game scores for a number of weeks. Our goal is to compute and output the percentage of wins for each team, as well as the total percentage of games won by the home team. The input will be given as a table that has a row for each team. The row will start with the team abbreviation, followed by an entry for each week of the season. The entries will be the opponent team, possibly preceded by an @ sign indicating the game was away (not home), and then the score in a #-# format. The first score is for the team represented by the row, and the other score is for the opponent. Here is an example for one team and 5 weeks, but there will be more weeks ultimately.

    BAL @CIN 20-0 CLE 24-10 @JAX 27-10 PIT 17-14 @OAK 14-20
    

The output should be a row for each team with their team name and winning percentage. For the example above, it would be "BAL 80% wins". Then the overall percentage of home games won for all teams should be displayed. Remember that @ means away, but that the first score is always for that row's team. Your pseudocode should work no matter how many weeks or teams there are in the input.


General assignment requirements, style and submission details: