Log in

View Full Version : Java homework assignment


Jess
January 17th, 2013, 07:21 PM
Yet another one. This one is due next Sunday, but I still need as much help as possible, before I go turn it in.


Write a tester program called RectangleTester that constructs two rectangles, calculates the perimeters of each rectangle, calculates the area of each rectangle, and then calculates the differences in the perimeters and the areas. (Use the getHeight and getWidth methods)

Print the differences using the System.out.println method

For your final submission RectangleTester should test two pairs of Rectangles. The rectangles of width, height 20,40 and 10, 35 and the rectangles 16, 30 and 18, 19.

Your output should be as follows: (it should match on spacing and capitalization and value)

Rectangle A Width 20.0 Height 40.0 Perimeter 120.0 Area 800.0
Rectangle B Width 10.0 Height 35.0 Perimeter 90.0 Area 350.0
Differences between A and B: Perimeter 30.0Area 450.0
Rectangle A Width 16.0 Height 30.0 Perimeter 92.0 Area 480.0
Rectangle B Width 18.0 Height 19.0 Perimeter 74.0 Area 342.0
Differences between A and B: Perimeter 18.0Area 138.0

Note: not asking you to do the homework for me....I still have trouble understanding Java and want to be guided in the right direction. Right now I haven't started on it, so no need to post tips or whatever.

ethanf93
January 17th, 2013, 07:54 PM
So I think the general consensus is the internet is not going to do your homework for you. If you have specific questions like "this doesn't work, why?" or "can someone explain this concept" we can help, but I don't see such a specific question.

Jess
January 17th, 2013, 11:24 PM
I'm not asking people to do the homework for me. I'm just asking for help, like on how to start it :/

TheMatrix
January 17th, 2013, 11:43 PM
Well, I did it for you. See attached.
Extract the two files to a directory(aka, "folder") of your choice, then run the batch script or just start Java using the command:
java -jar "JessAssignment_c.jar"
(they do the same thing)





Oh, you wanted the source? Well, it's supposed to be an assignment for you, not for me. :P
The source will post itself on Monday(21 January), to my blog (http://www.virtualteen.org/forums/blog.php?b=39515). Until then, you shouldn't see it.

Jess
January 18th, 2013, 01:21 AM
Thank you Thomas but you didn't need to do it for me. I want to be able to do it in the future by myself. Would it be all right with you if you also add some explanations as to why you use a certain coding, if you get what I mean?

TheMatrix
January 18th, 2013, 02:37 AM
Thank you Thomas but you didn't need to do it for me. I want to be able to do it in the future by myself. Would it be all right with you if you also add some explanations as to why you use a certain coding, if you get what I mean?

I suggest you read the code first, once I make it available -- I hope it's self-documenting(except in 3 probable places which I can explain if needed).

Heck, for the record, I'll "license" it under CC0 (http://creativecommons.org/publicdomain/zero/1.0/legalcode-plain).

Jess
January 18th, 2013, 03:22 PM
Okay. For the 3 probable places, yes please explain (when you make it available of course). Thanks again