Computer Science 210
Data Structures
Fall 2016, Siena College
This week's lab is a chance to practice a bit more using custom classes and the ArrayList ADT. While it is due at the usual time, hopefully you can finish up sooner to prepare for the exam.
You may work alone or with a partner on this lab. Only one submission per group is needed.
Getting Set Up
To get your BlueJ environment set up for this week's lab assignment, start BlueJ and choose "New Project" from the "Project" menu. Navigate to your folder for this course and choose the name "Lab4" (no spaces) for the project.
Create a document where you will record your answers to the lab questions. If you use plain text, call it "lab4.txt". If it's a Word document, you can call it whatever you'd like, but when you submit, be sure you convert it to a PDF document "lab4.pdf" before you submit it.
More Matrix2D
This problem builds on the Matrix2D program from last week. Start with your version of Matrix2D.java that includes the matrix-matrix multiply method.
Your program should behave as follows:
A sample run of the program follows:
What size should the matrices be? 4 Enter upper and lower bounds for values of the next matrix: 0 10 More matrices? (yes or no) yes Enter upper and lower bounds for values of the next matrix: -5 5 More matrices? (yes or no) yes Enter upper and lower bounds for values of the next matrix: 100 200 More matrices? (yes or no) no You created 3 matrices. Matrix 0: 9.68220530639116 7.345769488480678 1.7412544053873813 2.3438316061712605 3.1944624268586654 3.9513050924461313 4.267474531699351 2.583640677971447 4.641348346843794 3.5690041627188753 3.3537004228656233 6.340187059095067 2.098098670498576 7.140456953926631 7.855035765375354 2.5806587268338586 Matrix 1: 4.806713489353562 0.4135288039878944 1.2768161447453794 -4.068342594706581 3.6280471321371586 -2.5156720232308336 4.048496011548281 4.266635696913379 -3.039326003927366 1.1870583652796984 -4.750758409032128 0.5086397570974199 2.3554889820951885 -0.6787271394749981 2.6905416351814733 2.3593801046651217 Matrix 2: 149.83228384235943 130.59594399972167 158.3705270054091 169.4955788825903 110.50901258217934 185.2866551484843 149.6145308945793 120.91463311180807 180.23028479845289 177.20036526697353 151.46037517431358 174.51331981681983 125.26086320907847 112.274872082545 158.7914846584583 172.05826577250718 Sum of your matrices: 164.32120263810415 138.35524229219024 161.38859755554185 167.771067894055 117.33152214117516 186.7222882176996 157.93050143782693 127.7649094866929 181.8323071413693 181.95642779497211 150.06331718814707 181.36214663301232 129.71445086167222 118.73660189699663 169.33706205901512 176.99830460400617 Product of your matrices: 16482.548286913046 13922.983840001521 15352.500605703277 17474.653424398755 5567.009861117915 4553.491999143645 5766.601007853109 6489.223728863248 10682.275123478916 9126.782807692354 10552.788438086425 11877.89036959422 5902.680161976161 4421.1764573063265 6724.206610818697 7652.617790407841
Programming Assignment: Enhancing the CourseGrades Example
Start by making your own copy of the CourseGrades example, and read through the existing code to make sure you understand how it all works.
It is very important to make sure you understand which parts of the program are responsible for which computation and for storing the data. There are three major sections of the program:
A memory diagram of the variables in existience after the following commands are entered:
add 100 carrie add 87 barry add 91.5 carrie
and the program is currently executing the line
cg.add(name, grade);
in main, the (second) line
sg.addGrade(grade);
in the add method of CourseGrades, and has just finished the line
grades.add(grade);
in the addGrade method of StudentGrades.
Do not start making modifications until you understand the breakdown and memory diagram above.
You will be making several enhancements to this program:
average Alice
would print
Alice has an average of 88.5.
Print the average with one digit after the decimal point.
If the student is not found, print an appropriate error message.
delete Bob
If the student is not found, print an appropriate error message.
The command
save somegrades.dat
would save all of the student and grade information to the file somegrades.dat, and the command
load somegrades.dat
would load in the file, replacing any data currently in the program, and
merge somegrades.dat
would load in the file, adding to any existing data currently in the program.
You may choose your own appropriate file format.
You need not handle I/O exceptions in a nice way here. Just add "throws IOException" to the method headers of your main method and any others that create or user file Scanners or PrintWriters.
Submitting
Before 10:00 AM, Wednesday, October 5, 2016, submit your lab for grading. There are two things to do to complete the submission: (i) Copy your file with the answers to the lab questions into your project directory. Be sure to use the correct file name. If you prepared your answers in Word, export to a PDF file and submit that. and (ii) upload a copy of your lab (a .7z or .zip file containing your project directory) to Blackboard under "Lab4". Don't forget to check your programming assignment programs for compliance with the Style Guide for CSIS 210 Programs
Grading
This assignment is worth 70 points, which are distributed as follows:
> Feature | Value | Score |
Matrix2DList practice program | 20 | |
CourseGrades average command | 5 | |
CourseGrades delete command | 5 | |
CourseGrades save command | 5 | |
CourseGrades load command | 3 | |
CourseGrades merge command | 3 | |
CourseGrades stats command (basic) | 8 | |
CourseGrades stats command handles ties | 3 | |
CourseGrades updates to help command | 2 | |
CourseGrades comments | 5 | |
CourseGrades naming conventions | 2 | |
CourseGrades code organization | 2 | |
CourseGrades formatting | 1 | |
Lab Question 1 | 4 | |
Lab Question 2 | 2 | |
Total | 70 | |