HELP! Can someone help me with AP Computer Science?
I need to complete this lab in Edhesive by this week. The code below is what I have. I know how to do the second half of the assignment, but I don't know how to do two inputs and do a calculation with them.
The instructions are:
Write code which takes inputs and creates two Rectangle objects (using the edhesive.shapes.Rectangle class) and compares them using the equals method.
The first Rectangle should use a single user input and the single-parameter constructor, making a square Rectangle object. The second Rectangle should should use two user inputs and the second rectangle constructor. The code should then check the two objects for equality, printing "Congruent Rectangles" if they are identical according to the Rectangle equals method and "Different Rectangles" if they are not the same.
Sample run 1
Enter 2 lengths:
Sample run 2
Enter 2 lengths:
Thank you EddieJ for your response. I can create 2 rectangle objects, but how can I create the 2 inputs and compare them to see if they are congruent as stated in "compares them using the equals method.
The first Rectangle should use a single user input and the single-parameter constructor, making a square Rectangle object. The second Rectangle should should use two user inputs and the second rectangle constructor. "
If you can, can you please write out the very beginning of the code for me?
- EddieJLv 74 weeks agoFavorite Answer
Edhesive is a proprietary product, so I do NOT have access to it, so I cannot test any code that I might supply.
You need to create 2 Rectangle objects. It seems that you would do that with
Rectangle rec1 = new Rectangle (number1);
Rectangle rec2 = new Rectangle (number2, number3);
But, before you do that, you need to get the numbers. You are using scan.nextLine () but you probably want to use:
double number1 = scan.nextDouble ();
- 2 weeks ago
did you ever get the code for this problem? I have it and I cant figure it out.