I should not do your home work and also I don't have much experience in Java but a little boost up could help you I think so,
Declare a class like this
class HomeWork{
}
You need two methods , one to calculate area and other to perimeter...
Methods are nothing but functions so declare two functions, like this
class HomeWork{
void CalculateArea(double side)
{
System.out.println("Area: "+ side*side);
}
void CalculatePerimeter(double side)
{
System.out.println("Perimeter: "+ 4*side);
}
}
You can see that the functions are getting side like this, funtion(here it gets side)
since area is nothing but the square of side and perimeter is nothing but the sum of the sides. Here the tow functions are getting the side and doing the operations.
In order to call this function in your main class you need an object( you see that class is just a blue print and an object is called as a real world existing thing)
for "What Have you tried" I've taken the code
public class Calculate {
public static void main(String[ ] args) {
}
Ask the user to enter the side and store it in a variable..
public class Calculate {
public static void main(String[ ] args) {
System.out.println("Enter the side");
Scanner obj = new Scanner(System.in);
double s = obj.nextDouble();
}
Now you have to make use of an object to perform the operation
HomeWork object = new HomeWork();
object.CalculateArea(s);
object.CalculatePerimeter(s);
so there is your output
Here is the main code for your reference
public class Calculate {
public static void main(String[] args) {
System.out.println("Enter the side");
Scanner obj = new Scanner(System.in);
double s = obj.nextDouble();
HomeWork object = new HomeWork();
object.CalculateArea(s);
object.CalculatePerimeter(s);
}
}
For your ease kindly use this complete code
import java.util.*;
class HomeWork{
void CalculateArea(double side)
{
System.out.println("Area: "+ side*side);
}
void CalculatePerimeter(double side)
{
System.out.println("Perimeter: "+ 4*side);
}
}
public class Main {
public static void main(String[] args) {
System.out.println("Enter the side");
Scanner obj = new Scanner(System.in);
double s = obj.nextDouble();
HomeWork object = new HomeWork();
object.CalculateArea(s);
object.CalculatePerimeter(s);
}
}
My present knowledge in java ends here from here do refer some online tutorials or ask your Tutor( They get paid to help you) .
Please feel free to ask doubts.