Click here to Skip to main content
15,036,891 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
In this assignment, you are to write a handful of methods that perform common geometry calculations such as calculating the area of a circle, or the perimeter of a right triangle, or the volume of a box.

You are to write a handful of methods that perform common geometry calculations. Below are the headers of the methods you are to add to the Logic class contained in the file Logic.java. These are just the headers. Your job is to add each of these methods, including method header and method body, to the file Logic.java.

public static double rectangleArea(double length, double width)

public static double rectanglePerimeter(double length, double width)

public static double circleArea(double radius)

public static double circleCircumference(double radius)

public static double rightTriangleArea(double base, double height)

public static double rightTrianglePerimeter(double base, double height)

public static double boxVolume(double length, double width, double depth)

public static double boxSurfaceArea(double length, double width, double depth)

public static double sphereVolume(double radius)

public static double sphereSurfaceArea(double radius)

Each method should accept parameters as specified above, in the specified order. It is recommended that you simply copy-n-paste the above headers into your file. The methods should then perform the necessary calculations and return the results to the caller. What the methods compute is fairly obvious. For computing the area and perimeter of a triangle, we will doing so only for a right triangle with the given base and height (and thus the names of the methods).

Source code aesthetics (commenting, indentation, spacing, identifier names): You should properly indent your code. No line of your code should be over 100 characters long (even better is limiting lines to 80 characters). You should use a consistent programming style. This should include the following.

 Meaningful variable & method names
 Consistent indenting
 Use of "white-space" and blank lines to make the code more readable  Use of comments to explain pieces of tricky code
 Comment headers on all methods that explain what the method computes and any pre- or post-conditions.

What I have tried:

I haven't tried a thing. This assignment has me totally stumped, and as for google searches, I don't even know what to query.
Posted
Updated 21-Oct-20 7:38am
Comments
Jim Meadors 28-Jan-18 22:26pm
   
You should review your class materials. The assignment is easy and all you have to do is look up the math that you need for each function and then return the result of that equation.
Member 13648759 30-Jan-18 14:01pm
   
It's a coursera MOOC. Java For Android from Vanderbilt. I don't know where or what I missed out on. But I lost track along the way. Thanks for the guidance Jim. This all still seems like a foreign language to me.
Jim Meadors 31-Jan-18 10:45am
   
Go back to a point where it was still making sense to you and clear up anything you don't understand there and then try to study the materials forward from there again. It will make more sense that way.
David Crow 29-Jan-18 12:32pm
   
"The assignment sounds very simple, but I am still grasping at straws on what exactly they want. I don't want the answer. Just some direction. Here is what I was given for direction: You are to write a handful of methods that perform common geometry calculations."

Everything BUT the answer has been provided to you. Do you know how to calculate the area of a rectangle using pencil and paper? How about the area of a circle? If you cannot do that, save yourself much frustration and move on to something else.

"SO I decided to jump into Java..."

Did you skip the chapter on how to create functions and how they can return values?
Member 13648759 30-Jan-18 14:03pm
   
Thank you David you have given me insight. All I need is guidance. You have given me a bit. Much appreciation.
phil.o 30-Jan-18 15:45pm
   
If you just discover java and development's vocabulary, it can be hard to grasp all concepts at once. Thing is, it's hard for us to know how to guide you. Maybe you should begin with a basic java tutorial, as well as familiarizing with OOP concepts. There are plenty available. Then, about your actual problem, maybe ask very precise questions related to your assignment (eg., 'What is a method?', or 'What is consistent indenting?', or 'What is a pre/post condition?'. For now, it is very hard for us to guess what you need to know, what confuses you most.
If you decide to accept to climb the necessary learning curve, you may enjoy development; it will teach you to think about problems and bring concrete solutions to solve them.
Kindly.
Member 13648759 1-Feb-18 12:31pm
   
Thank you for the positive outlook Phil. I won't give up. I've decided to fight it out and stick it out. I am trying and learning. Which actually feels good but still foggy.

So, you show no attempt to solve the problem yourself, you have no question, you just want us to do your HomeWork.
HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is learning and practicing.

We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
Quote:
I haven't tried a thing. This assignment has me totally stumped, and as for google searches, I don't even know what to query.

This assignment is among the most easy you will ever have. If you can't do a thing, not even find the maths, think about another job.
[Update]
Quote:
What I am seeking is some guidance.

There is no guidance other than doing the job. Answers are so short that they fit in 1 line of code.
Advice: find another tutorial, follow it. What you need is one of the very first things you learn.
   
v3
Comments
Member 13648759 30-Jan-18 14:08pm
   
Sorry you think I am trying to get you to do my home-work. It's nothing like that. What I am seeking is some guidance. Just a nudge in the right direction. It may seem all simple to you, but for me all I see is a strange language which am trying to wrap my brain around. The course I am attempting is a MOOC. Coursera MOOC. Java For Android by Vanderbilt University. I do understand the logic behind and your reasoning. I appreciate the input and guidance. I shall take your advice into account.
Consider the first one in the assignment:
Java
public static double rectangleArea(double length, double width)

So the method named rectangleArea takes two input parameters which are double types, namely length and width. It returns a double value, which the method is required to calculate.

So all you need to do is to write the code to do that calculation, which is not exactly difficult.
   
Comments
Member 13648759 30-Jan-18 14:10pm
   
Oh.. I see.. Wow. Thank you very very much. So simple.. That's all I needed. A little guidance. I appreciate your explanation.
Richard MacCutchan 31-Jan-18 3:26am
   
You need to understand that programming is not so much about writing code, but understanding and using logic.
David Crow 31-Jan-18 9:34am
   
A lost art these days I'm afraid. Too many want to jump straight to the keyboard.
Member 13648759 1-Feb-18 12:35pm
   
How do I avoid falling deeper into this trap of just wanting to jump to the keyboard and start making things happen. How do I become better at logic as it relates to coding?
Member 13648759 1-Feb-18 12:34pm
   
I see. I do have a lot to learn. I would originally have thought it to be like human language. Learn the meaning of words and use them where applicable.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900