promotion image of download ymail app

Having major issues with programming project, dont know where to start... Due on 11/13, HELP!?

I really need help on this, i dont even know where to start Q_Q

* Assignment 4: Text I/O & Networking *


Write Java programs that use text I/O and networking.

Networking: Longest String

Write a class “Longest” that implements a server program waiting for clients at port 5150. Each client contacting the server will send one or more words in one line of text. The server will read all words from a client and return the longest word. The server closes its communications with a client after sending the longest word.

The server will continue receiving clients until the longest word is “bye”. When this word is the longest the server will shutdown.

Text I/O: Matrix Multiplication

Write a class “Matrix” that implements the method:

public static void multiply(File file)

This method receives a file object from which to read 2 numeric matrices. The method multiplies the matrices and writes the result matrix back to the given file.

Matrices in the input file are placed side by side. For example, the data below represents a 4x2 matrix (left) and a 2x3 matrix (right). Note that row 1 of BOTH matrices is always on the first line of the file, and that there will be no blank lines in the file.

1 2 1 2 3

3 4 4 5 6

5 6

7 8

Multiplying these matrices result in the 4x3 matrix below (review matrix multiplication:, scroll down to “Product AB”).

9 12 15

19 26 33

29 40 51

39 54 69

Method “multiply” will read the input file, calculate the sizes (if possible) of both matrices, determine the size and contents of the resultant matrix, and write the results to a file. The format of this output file will match the examples above: one line per row, elements separated by one space.

For more examples of matrix multiplications, please see the test cases. You can run the numbers manually at

Follow this algorithm:

1. Read the whole file to get the dimensions of matrices A and B. You want to find C.

A * B = C

r1 x c1 * r2 x c2 = r1 x c2

2. Count the number of lines up until you see whitespace at character 0 or reach the end of file. This is “r1”. If there are lines with whitespace at character 0, then “r2” is the number of lines in the file; otherwise, “r2” is unknown for the moment.

3. If “r2” is still unknown, analyze the file’s input and note the number of integer tokens per line. The line where the count drops is the line where B ends. “r2” is the line count before this point. If “r2” is still unknown, then r2 is the number of lines in the file.

4. c1 = r2 (matrix multiplication prerequisite).

5. Analyze the first line of input again, counting integers. Make this count be “cX”, so that

c2 = cX - c1

6. Create 2D arrays: A = r1xc1 and B = r2xc2

7. Analyze the input file again. On line one, read “c1” integers into A and “c2” integers into B. Do this for “R” rows, where “R” is the smaller of “r1” and “r2”.

8. For the rest of the rows, read in “C” integers, where “C” is the smaller of “c1” and “c2”. Read these into A if r1 > r2 or into B if r2 > r1.

9. Multiply the two matrices and write the result to the given file.

If at any point the number of tokens is not what is required, or if the dimension of matrices is illegal for multiplication, your method should throw an “IllegalMultiplicationException” (make it a subclass of “RuntimeException”).

JUnit Test

Use the files “” and “” (downloadable from Scholar) to test your implementation. Your program should not hard-code its answers.

Submission & Grading

All students submit your “*.java” files to Scholar (make sure to press “Submit” after uploading them). This means that all partners should submit all code.

Add to the first line at the top of your files the percentage effort made by partners in the assignment (if you had one). For example,

* “// John Doe 50%, Jane Doe 50%” indicates that both partners made equal effort.

* “// Jack 100%, Jill 0%”, indicates that Jack did the assignment with no help from Jill.


2 Answers

  • 8 years ago
    Favorite Answer

    I am boaring on reading your question.

    Source(s): SsantanuberaA
    • Commenter avatarLogin to reply the answers
  • 4 years ago

    Harryd,,,,, you are taking the prize super answer, Our freedoms have been eroding slowly, small bits reduce away very subtely. We have had some horrible laws encacted given that 11th of September. There are some problems with the Patriot act. Lots of problems with DHS. These two government errors, have price this nation dearly. We now have damn close elevated executive by way of a 1/four of its size. States rights damn near no longer exsist, Federal executive is micro managing what we do in our day-to-day lives. This has to discontinue. This nation wishes to pull its head out of it is ***, and tearing down the partitions in DC figuratively, start with calling campaigns, E- mail campaigns Let these elected officals comprehend they don't seem to be doing there job, if you have a senator or congressman strolling for re-election let that individual recognize that your particularly not glad. List matters you want carried out, get a bunch of people to record matters you need achieved. Name the Congressional individuals place of job and voice complaints. Most of all. We ought to have the option, to make the confident transition to higher government,. We the persons are responsible for this mess, now not the damn congress or the President we are. We've got been sitting on our arms for the past 30 years and have allowed this **** to happen. So do not blame the man subsequent to you blame your self, Now we need some rather wise, committed persons who can aid us do the proper thing. Repeal unhealthy legal guidelines, bolster just right laws. Eliminate this damn IRS period,,, this is the Politicans cash cow. . If it comes to it,,,, discover a nice candidate and kind a brand new social gathering or bolster the unbiased get together. Make it the giant canine on the block.. And handiest put individuals within the seats that reflect what you the persons need finished, and now not some asshole congressman.. Good if nothing else I certain believe higher.,

    • Commenter avatarLogin to reply the answers
Still have questions? Get your answers by asking now.