IS 2033 – PA4 ASSIGNMENT solution

$25.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (4 votes)

OBJECTIVE: Code a program that uses the concepts covered in chapters 1-7 and lecture. This is
not the program purpose!
PREP WORK: Chapters 1-7 (see Ch 7 Arrays of Objects PowerPoint slides posted with this PA); and
all labs up through the present.
GRADING: You’ll be graded on how well you follow the program instructions and the accuracy of
your output as reflected in the prompts, the output specifications, and the sample output. The
instructions, prompts and output are what the user wants. You are not at liberty to change anything,
but code to these requirements.
PROGRAM INSTRUCTIONS: Code a program that tracks the wins-losses of the athletic teams at
your school. Create 3 separate class files in a project folder; declare variables at the class level;
create and use a one-dimensional (1D) array typed as the Team class so it can contain team objects;
use the for loop to populate the array and extract data from the array; and code multiple methods.
1. Download the Creating Projects in DrJava PDF (instructor’s version) on how to create a project
folder that manages multiple .java files stored in the same folder. The project folder has the same
name as the group .java file. You are creating 3 separate .java files to be stored in the project
folder:
a. GroupMembersLastNamesSectionNoPANo.java contains only the main(),
b. TeamStats.java, and
c. Team.java.
2. The main() will instantiate (create) an object of the TeamStats class and use that object to call
start(). Make sure you exit main().
3. The TeamStats class will have 4 methods: an empty constructor, start(), processWinsLosses(),
and displayTeamsStats(). There are NO value-returning and/or value-receiving methods in the
TeamStats class. You will create a 1D array called myTeams at the class level as a null array.
The type for this array will be Team.
a. In start(),
1) if the answer is “Y” to tracking the performance of your teams then
processWinsLosses() and displayTeamsStats() are called;
2
2) otherwise the program exits with this message: Thank you! Exiting program.
b. In processWinsLosses(), the user is prompted for the number of teams to be tracked by the
program. That number will be used to give size to the myTeams array.
c. In displayTeamsStats(), the output is printed according to specs (see sample output).
d. Your output will have uppercase and lowercase for the same word in different parts of the print
out. You’ll need two (2) methods from the String class: toLowerCase() and toUpperCase().
Use the String variable to call these methods. Example: school.toUpperCase() where
school is the String variable that stores the school’s name.
4. The Team class will have the set methods to capture the team information and the get methods
to return the captured data.
a. Code an empty constructor.
b. Code an overloaded constructor that accepts the data for the team and its coach. Assign the
parameter variables to global variables with the same name.
c. Code a method called setTeam() that prompts for each team type.
d. Code a method called setCoach() that prompts for the team’s coach.
e. Code a method called setTotalGames() that prompts for the total number games played by
the team.
f. Code a method called setWins() that prompts for the team’s number of wins.
g. Code get methods for each global variable that has a set method. These get methods only
return the global variables.
5. Code at the class level only those variables that need to be used by more than one method.
6. Develop your code by planning the logic first. You will only pseudocode the plan for the
Team class. The plan is worth 10% of your grade. Save your plan as
GroupMembersLastNamesSecNoPA4Plan. Download the plan instructions and the plan template
through the links posted for this assignment on Blackboard. There is an example of a PA4 plan
on Blackboard. Use that to assist with your plan.
a. The prompts will tell you what input variables you will need.
b. The output will tell you the type of calculations you will need (if any) and whether you will need
to declare additional variables.
c. The output will tell you the order of logic for your code.
7. Please work in groups of only two from the same section. The group will only submit one
plan and one project with all the files. This means only one of the group members can
submit the PA. I will ignore all submissions if both group members post submissions. The
3
project folder and the main() file will reflect the last names of both group members. E.g.,
CosbyHuxtable001PA4. Through line and method comments, group members will claim
authorship and the work has to be evenly distributed. Example:
int age = 0; //By Bill Cosby: STORES AN AGE
/**
*By Cliff Huxtable
*main() captures a first and last name, an age, and a zip code.
*It multiplies the age and zip code to get a product.
*Output will be made to the console screen and to a
*GUI window.
*/
WARNING: One group member CANNOT and MUST NOT carry the load for these assignments.
All group members have to be actively engaged in developing and writing code to do well on the
exams and in Java II.
8. Program Documentation: In your program, YOU MUST insert a program purpose in the first
comment box. The content of that first comment box was shown to you in the Anatomy of a Java
Program lecture for chapter 1. Use Javadoc comment boxes beginning with /** and ending with
*/. Insert a Javadoc comment box above each of the methods in each of the programs explaining
what is going on. Line comment the import statements and the variables. Comments are worth
16 points.
9. Formatting Rules:
a. Double-space after colons and end-of-sentence punctuation.
b. Single-space after commas and semicolons.
c. Line advances for prompts, messages, and final output.
1) Prompts and final output:
a) When printing lines between the first and the last:
i. Using a printf without “%n” gives you no line advances.
ii. Use one “%n” after each printed line to print the next line, especially when the
output is concatenated in one printf statement. There’s no blank line between
printed lines.
iii. Use two “%n” after each printed line to double-line advance between lines,
especially when the output is concatenated in one printf statement. There’s one
blank line between printed lines.
iv. Use three “%n” after each printed line to triple-line advance between lines,
especially when the output is concatenated in one printf statement. There’s 2
blank lines between printed lines.
b) When printing the first line:
i. Use one “%n” for a double-line advance.
ii. Use two “%n” for a triple-line advance and so forth.
2) Messages: Messages that are not prompts should begin with “%n” and end with “%n” to
facilitate double-line advancing before the message and before the printed line after the
message.
3) Always test your output to validate that your program is functioning properly with the correct
output and spacing.
4
PROMPTS: Code the bold from the prompts below in the printf statements that capture data into
your program. Once again, the prompts tell you your input variables. Keep in mind that these
prompts are not all in the same class.
1st Prompt: Code in start(). The method start() will be the only method from the TeamStats class
called by the main().
Do you want to track the performance of the athletic teams at your school? Enter ‘Y’ or ‘N’:
If the answer to the above question is “N” display the following message:
Thank you! Exiting program.
If the answer is “Y” then proceed to prompts 2 through 7.
2nd Prompt: Code in processWinsLosses().
What is the name of your school?
3rd Prompt: Code in processWinsLosses(). The value captured here is the size of the array called
myTeams.
How many athletic teams do you have at your school?
4th Prompt: Code in setTeam().
Enter the team type:
5th Prompt: Code in setCoach().
Enter the name of the coach:
6th Prompt: Code in setTotalGames(). The Xs represent the type of the team (basketball, football,
etc.). Note the team type is all lowercase.
Enter the total number of games played for the xxxxxxxxxxxx team:
7th Prompt: Code in setWins(). The Xs represent the type of the team.
Enter the number of wins for the xxxxxxxxxxxx team:
FINAL OUTPUT SPECIFICATIONS: The output will print the header, the team’s name, the coach,
the total number of games played, the number of wins, the number of losses and the win percent as a
decimal. There are multiple teams which is why the output specs are repeated. The number of
losses is calculated. The header should be triple-line advanced from the last prompt or output. The
printing of the output will be in a method called displayTeamsStats() from the TeamStats class. The
Xs in the header is the school name.
5
TEAMS WIN-LOSS RECORD FOR XXXXXXXXXXXX
Team: Xxxxxxxxxxxx
Coach: Xxxxxxxxxxxx
Total Games: ZZ9
No. of Wins: ZZ9
No. of Losses: ZZ9
Win Percent: Z9.99%
Team: Xxxxxxxxxxxx
Coach: Xxxxxxxxxxxx
Total Games: ZZ9
No. of Wins: ZZ9
No. of Losses: ZZ9
Win Percent: Z9.99%
***END OF OUTPUT SPECIFICATIONS***
SUBMISSIONS REQUIREMENT:
1. Zip Your Project Folder:
a. Insert your plan into the project folder.
b. To zip the folder, point to it then right click and
i. Filzip if you have it OR
ii. Click Send To then click Compressed (zipped) Folder
2. Uploading to Blackboard: Make sure your browser is properly configured for Blackboard
(see syllabus).
a. Your submissions are to be uploaded to Blackboard through Assignments only.
b. Upload the zip file AND the Word document separately, but no later than the due date by
11:55 pm; otherwise, you don’t have time to recover from any problems and your assignment
may not be accepted by Blackboard.
c. Check to make sure your submission is uploaded. Please do not ask me to check whether
your assignment has been uploaded. You can do this yourself. Or upload during a tutoring
session when someone can help you.
d. If you submit your assignment before the due date, want to make changes or upload additional
files, you can re-upload your files.
3. NO ASSIGNMENTS WILL BE ACCEPTED LATE OR VIA E-MAIL EVEN IF YOU HAVE
TROUBLE UPLOADING YOUR SUBMISSION ON BLACKBOARD. IF YOU HAVE TROUBLE,
TRY ANOTHER BROWSER OR SUBMIT EARLY SO YOU CAN DEAL WITH ANY PROBLEMS.
*****SAMPLE OUTPUT WHEN ANSWER IS “N”*****
Do you want to track the performance of the athletic teams at your school? Enter ‘Y’ or ‘N’: n
****SAMPLE OUTPUT****: It is always good to test your code using sample data to see if your
program meets the output specifications. Run your program using the VER. 3 data from the
sample output. Copy and paste the output into a comment box at the end of your PA4 .java
file the one with the main(). The comment box needs to be outside of the close brace for the
class. Worth 5 points!
Headers (Titles): Triple-line advance
1
st line of header title using 2 “%n”. All
capital Xs means all CAPS.
6
Thank you! Exiting program.
*****SAMPLE OUTPUT WHEN ANSWER IS “Y”*****
Do you want to track the performance of the athletic teams at your school? Enter ‘Y’ or ‘N’: y
What is the name of your school? Ace High School
How many athletic teams do you have at your school? 3
Enter the team type: Basketball
Enter the name of the coach: Warner
Enter the total number of games played for the basketball team: 14
Enter the number of wins for the basketball team: 8
Enter the team type: Football
Enter the name of the coach: Phillips
Enter the total number of games played for the football team: 12
Enter the number of wins for the football team: 10
Enter the team type: Baseball
Enter the name of the coach: Robins
Enter the total number of games played for the baseball team: 30
Enter the number of wins for the baseball team: 12
TEAMS WIN-LOSS RECORD FOR ACE HIGH SCHOOL
Team: Basketball
Coach: Warner
Total Games: 14
No. of Wins: 8
No. of Losses: 6
Win Percent: 57.14%
Team: Football
Coach: Phillips
Total Games: 12
No. of Wins: 10
7
No. of Losses: 2
Win Percent: 83.33%
Team: Baseball
Coach: Robins
Total Games: 30
No. of Wins: 12
No. of Losses: 18
Win Percent: 40.00%