Sale!

CPSC 2151 Lab 2

$40.00 $24.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (2 votes)

In this lab you will be working with java and the intelliJ IDE, as well as making your first lab
report.
Let’s start by opening up IntelliJ on your computer. Create a new project by selecting File->New-
>Project. ON the next screen you should already have an SDK selected (if not, it is available under
C:\Program Files\Java). Do not select any additional frameworks, hit next. On the next screen, do not
select the check box that says “Create Project from Template.” Hit next. Name your project MatrixFun,
choose a location to save it (on the U drive, not the C drive). Once your project has been created, add a
package called cpsc2150.lab2 and a class called MatrixApp in a file called MatrixApp.java.
Write a java program that will allow the user to create a matrix (2D array) with a size of their
choosing (max of 10 by 10). You must use a 2D array, not lists or other resizable collections. The
program should make sure the user does not select a size larger than 10 by 10. The user will then ask
them fill in numbers for the matrix. After that, the program will ask the user to enter the numbers to fill
their matrix, each time reminding the user of the position they are currently filling. After the matrix has
been filled, it should be printed to the screen.
The program will then have functions that solve for the following
1. A function that takes in a matrix (and it’s dimensions) and returns the transpose of a matrix.
https://en.wikipedia.org/wiki/Transpose if you are unfamiliar with matrices.
2. A function that solves for the product of the sums of each row, i.e. sum all the numbers in
row 1 and multiply it by the sum of the numbers in row 2 and so on.
3. A function that finds the average of all of the numbers in the matrix
4. A function that returns an array with where arr[i] is equal to the sum of all the numbers in
the ith column in the matrix.
5. A function that returns an array with where arr[i] is equal to the sum of all the numbers in
the ith row in the matrix.
The program will call all of these functions and print the results to the user. Additionally, a separate
function should be written to take in a 2D array (and it’s dimensions) and return a string representation
that can be printed to the screen. See the sample output below. You may define any extra helper
functions that you may want. All functions that are not the main function should be private.
TIPS and additional Requirements
– You do not need to handle bad input from the user, assume they are entering integers
– Remember that the Integer class comes with helpful member functions
– Remember your import statements
– Your main function will be a static member function of your Main class. A static function can
only call other member functions of the same class if those member functions are also static
– Comments are required for your code to receive full credit.
– Your class should not have any non-constant data members. All data should be passed to the
functions via parameters.
– You should only print to the screen or get input from the user in the main function, not in any
helper functions. You can return a string from a function to be printed to the screen.
– You can use some of these functions to help solve other functions. Try to think of ways to do this
(hint, transposing a matrix can help).
– You do not need to create a new class for matrices.
Lab Report
Along with your code you must submit a well formatted report with the following parts:
Requirements Analysis
Fully analyze the requirements of this program. Express all functional requirements as user
stories. Remember to list all non-functional requirements of the program as well.
Design
Create a UML Activity Diagram for your main function, your function that converts the 2D array
to a formatted string, and your transpose function. These diagrams should be created electronically so
they are easy to read. I recommend draw.io
Testing
Describe how you tested your program to ensure it was functioning correctly. We have not
covered testing in detail this semester, so the requirements at this point are pretty relaxed. Just describe
your testing process. Include what specific inputs you used, and how you expected the program to react
to those inputs. Make sure to test your program thoroughly.
Deployment
Provide instructions about how your program can be compiled and run on unix
Your lab report should be one file, and converted to a PDF
Groups
You may, but are not required to, work with a partner on this lab. Your partner must be in the
same lab section as you, not just the same lecture section. If you work with a partner, only one person
should submit the assignment. You should put the names of both partners in a comment at the top of
the file and in the lab report in order for both partners to get credit. This assignment may take more
than just the lab time. Make sure you are able to meet outside of class to work on the assignment
before you decide to work with someone else. Remember to actively collaborate and communicate with
your partner. Trying to just divide up the work evenly will be problematic.
Before Submitting
You need to make sure your code will run on Unix. In order to do that you will first need to log
onto the unix machine and create a new directory. Our directory has to match the package we created
for our assignment. Create a directory named “cpsc2150” and then inside of that directory create the
“lab2” directory. Now move your code file to the unix machine into the lab2 directory. The code file will
be in the MatrixFun directory that IntelliJ created (you chose the location) under src/cpsc2150/lab2.
Once you have moved the file over, compile and run the program.
Submitting your file
You will submit your file using handin in the lab section you are enrolled in. You must also
submit your lab report as a pdf. Labs are not accepted late. If you are unfamiliar with handin, more
information is available at https://handin.cs.clemson.edu/help/students/
Sample input and outputs:
Example 1:
How many rows should your matrix have?
2
How many columns should your matrix have?
3
What number should go in Row: 0 Col: 0
4
What number should go in Row: 0 Col: 1
4
What number should go in Row: 0 Col: 2
4
What number should go in Row: 1 Col: 0
5
What number should go in Row: 1 Col: 1
5
What number should go in Row: 1 Col: 2
5
Your matrix is:
|4|4|4|
|5|5|5|
The transposed matrix is:
|4|5|
|4|5|
|4|5|
The product sum is:
180
The average is:
4.5
The sums of each Row are:
|12|15|
The sums of each Column are:
|9|9|9|
Process finished with exit code 0
Example 2:
How many rows should your matrix have?
3
How many columns should your matrix have?
3
What number should go in Row: 0 Col: 0
1
What number should go in Row: 0 Col: 1
2
What number should go in Row: 0 Col: 2
3
What number should go in Row: 1 Col: 0
4
What number should go in Row: 1 Col: 1
5
What number should go in Row: 1 Col: 2
6
What number should go in Row: 2 Col: 0
7
What number should go in Row: 2 Col: 1
8
What number should go in Row: 2 Col: 2
9
Your matrix is:
|1|2|3|
|4|5|6|
|7|8|9|
The transposed matrix is:
|1|4|7|
|2|5|8|
|3|6|9|
The product sum is:
2160
The average is:
5.0
The sums of each Row are:
|6|15|24|
The sums of each Column are:
|12|15|18|
Process finished with exit code 0
Example 3:
How many rows should your matrix have?
12
Error: Please enter a number 1-10
How many rows should your matrix have?
0
Error: Please enter a number 1-10
How many rows should your matrix have?
5
How many columns should your matrix have?
12
Error: Please enter a number 1-10
How many columns should your matrix have?
0
Error: Please enter a number 1-10
How many columns should your matrix have?
2
What number should go in Row: 0 Col: 0
5
What number should go in Row: 0 Col: 1
6
What number should go in Row: 1 Col: 0
78
What number should go in Row: 1 Col: 1
37
What number should go in Row: 2 Col: 0
42
What number should go in Row: 2 Col: 1
95
What number should go in Row: 3 Col: 0
6
What number should go in Row: 3 Col: 1
1
What number should go in Row: 4 Col: 0
42
What number should go in Row: 4 Col: 1
15
Your matrix is:
|5|6|
|78|37|
|42|95|
|6|1|
|42|15|
The transposed matrix is:
|5|78|42|6|42|
|6|37|95|1|15|
The product sum is:
69148695
The average is:
32.7
The sums of each Row are:
|11|115|137|7|57|
The sums of each Column are:
|173|154|
Process finished with exit code 0