HELPPP WITH JAVA I need this to be done in 3 hours and i can't

I have no time to figure this out and I really don't know how to do it, it's the last grade of the semester and my GPA rests on it's shoulders more than you'd think.  I don't want to do anything more in computer science, I just took the class so it's not like it's necessary for me to know how to do this.  I really need the answer to this so someone please give it to me!  it's in Java

 

Assignment 7 on Chapter 8

 

Step 1: Write the class declaration for class Square that has a private instance variable side of type double and a no-argument constructor that sets the side to 1.0 by calling a method named setSide that you will declare in step 2.

 

Step 2: Write a method setSide for the class you defined in step1. Set the side variable to the argument of the method. Also make sure that the side is not less than 0.0. If it is, keep the default setting of 1.0.

 

Step 3: Write a method getSide for the class you modified in step2 that retrieves the value of instance variable side.

 

Step 4: Define another constructor for the class that takes one argument, the side, and uses the Square’s set method to set the side.

 

Step 5: Write a method computeArea for the class that computes the area of a Square.

 

Step 6: Define a toString method for the class that will return a String containing the value of side and the area of the Square.

 

You may use the SquareTest below to test your assignment:

 

 

import java.util.Scanner;

 

public class SquareTest

 {

 // set up GUI components and instantiate new MyRectangle

 public static void main( String args[] )

 {

 Scanner input = new Scanner( System.in );

 

 // create a new Square with no initial values

 Square square = new Square();

 

 System.out.print( "Please enter a double value for the side of the square: " );

 

 double double1 = input.nextDouble();

 

 square.setSide( double1 );

 

System.out.println( square ); // see the results of the test

 } // end main

} // end class SquareTest

I hate to be harsh. But have you even tried? Did you go to the classes that explained the concepts of your homework ? People won't do it for you but if you come here having tried, people will point you in the right direction for the areas you're struggling with.

Seeing as how you don't really need to know this, but the assignment will affect your gpa, I am willing to lend you a hand. Give me a minute. I will try to make sure to get it back to you in time. Not guarantee about anything though. This is just from the kindness of my heart, from one struggling student to another.

Its also on the internet, someone literally asked the exact same question on this forum a year ago. All you need to do is google it.

Then the next year, they will be able to find this thread with the answer along with it.

Honestly though, this was a really simple task. I just finished the first CS class for my university, and this was MUCH simpler than what we typically do. Is this just like a simple version of the class or something? I can't imagine that this is what the CS majors need in order to prepare them for the rest of the courses they will be taking.

Screw it. Here is what I wrote. I am giving no promises that this works. I didn't compile it, I didn't test it with that test code. All I did was throw it together. Look it over yourself.

 

public class Square {
  private double side;
 
  public Square(){
    setSide(1.0);
  }
 
  public void setSide(double to_set){
    if(to_set<0.0)
      side = 1.0;
    else
      side = to_set;
  }
 
  public double getSide(){
    return side;
  }
 
  public Square(double length){
    setSide(length);
  }
 
  public double computeArea(){
    return side*side;
  }
 
  public String[] toString(){
    String ary[] = new String[2];
    ary[0]=getSide();
    ary[1]=computerArea();
  }
}