I wrote a program to take two values from the user that will determine perimeter and area of a rectangle. However, when I run the program, it is only adding the area input values together instead of multiplying them, and it always returns me 0 for the perimeter value.
I assume here that java respects standard math order of operations, but the java class that I'm taking right now has not gone that in depth with math statements. Here is the code snippet that handles the math:
/** * This method will take the inputs from the RectangleProgram class and calculate * the area & perimeter. */ public void rectData(double widthIn, double heightIn) { // Set width value widthInput = widthIn; // Set height value heightInput = heightIn; // Calculates perimeter of rectangle rectPerimeter = widthInput * heightInput; // Calculates area of rectangle rectArea = (widthInput * 2) + (heightInput * 2); }
Does anything look off here?