This is Java
0) Create a project called Lab2-Areas
1) Create a java class called Areas (do not include the main method
in this class)
2) Create a method for the following:
- areaCircle
- areaSquare
- areaTriangle
- areaRectangle
- areaTrapezoid
3) Create another class called CalculateAreas
4) Have the main method in this class. Instantiate/Construct the
Area object
5) Initialize variables for the appropriate sides (base, height,
etc.)
6) Initialize variables for the 5 areas from the Area class
7) print out the 5 area
class Area
{
//data member
double r;
double s;
double l;
double b;
double a;
double h;
double aa;
double bb;
double cc;
double at;
double bt;
double ht;
//set method
public void setCircle(double rad)
{
r = rad;
}
//set method
public void setSquare(double side)
{
s = side;
}
//set method
public void setTriangle(double aa1, double bb1, double cc1)
{
aa = aa1;
bb = bb1;
cc = cc1;
}
//set method
public void setRectangle(double length, double bredth)
{
l = length;
b = bredth;
}
//set method
public void setTrapezoid(double at1, double bt1, double ht1)
{
at = at1;
bt = bt1;
ht = ht1;
}
//metho to calulate area of circle
public double areaCircle()
{
return 22 / 7.0 * r * r;
}
//metho to calulate area of square
public double areaSquare()
{
return s * s;
}
//metho to calulate area of triangle
public double areaTriangle()
{
double s = (aa+bb+cc)/2;
return Math.sqrt(s*(s-aa)*(s-bb)*(s-cc));
}
//metho to calulate area of rectangle
public double areaRectangle()
{
return l * b;
}
//metho to calulate area of trapezoid
public double areaTrapezoid()
{
return (at+bt) * ht / 2;
}
}
public class CalculateAreas
{
public static void main(String[] args)
{
//create object
Area a = new Area();
//set value
a.setCircle(4);
a.setSquare(4);
a.setTriangle(5, 4, 3);
a.setRectangle(2, 4);
a.setTrapezoid(2, 4, 6);
//display the result
System.out.println("Area of circle
is = " + a.areaCircle());
System.out.println("Area of square
is = " + a.areaSquare());
System.out.println("Area of
triangle is = " + a.areaTriangle());
System.out.println("Area of
rectangle is = " + a.areaRectangle());
System.out.println("Area of
trapezoid is = " + a.areaTrapezoid());
}
}
OUTPUT:

This is Java 0) Create a project called Lab2-Areas 1) Create a java class called Areas...
JAVA LANG PACKAGE Create a NetBeans project for this activity. 1: Create a new class with attributes name and address. Both data type will be String. Create a constructor and assign the parameters to the attributes. Now override the to String() method. 2: Create a class with the main method and create an instance of the class that you created 3: Create an instance of the string in your test class and assign a value. 4: Now create an String...
Create a class Circle with one instance variable of type double called radius. Then define an appropriate constructor that takes an initial value for the radius, get and set methods for the radius, and methods getArea and getPerimeter. Create a class RightTriangle with three instance variables of type double called base, height, and hypotenuse. Then define an appropriate constructor that takes initial values for the base and height and calculates the hypotenuse, a single set method which takes new values...
Java Framework Collection Assign. Create a class called ArrayListExample Create a ArrayList object called languageList which accept type of String Add English, French, Italian and Arabic strings into languageList array object Print languageList using Iterator object Sort ArrayList object alphabetically Print languageList using Iterator object Solution will produce following: ArrayListExample class ArrayList object called languageList ArrayListExampleTest class with main method
JAVA Create a Java project to implement a simple Name class. This class will have the following class variable: First Name, Middle Name, Last Name, and Full Name Create the accessor/getter and mutator/setter methods. In addition to these methods, create a toString() method, which overrides the object class toString() method. This override method prints the current value of any of this class object. Create a main() method to test your project.
In Java: Requirements: 1. Create a class called Bike. 2. Create these private attributes: int currentSpeed int currentGear String paintColor 3. Create a constructor that takes 2 arguments: speed, gear, color. 4. Create another constructor that takes no arguments. 5. Create a method called goFaster(int amount) which increases the speed by the given amount. 6. Create a method called brake() which sets the speed to 0. 7. Create a method called print() which describes the bike and the speed it...
In this assignment you will create two Java programs: The first program will be a class that holds information (variables) about an object of your choice and provides the relevant behavior (methods) The second program will be the main program which will instantiate several objects using the class above, and will test all the functions (methods) of the class above. You cannot use any of the home assignments as your submitted assignment. Your programs must meet the following qualitative and...
Create another Java class named EmployeeMain within the same project, which includes the main method. a. Include another class named Employee in the same Java file. This class has the following instance variables and instance methods. Define all the instance/static variables with private access modifier and constructors, instance/static methods with public access modifier. Instance Variables empID: int employeeName: String basicSalary: double Constructor Set the value for empID. Instance Methods Get and set methods for all instance variables. displayEmployee: Display the...
For this question you must write a java class called Rectangle and a client class called RectangleClient. The partial Rectangle class is given below. (For this assignment, you will have to submit 2 .java files: one for the Rectangle class and the other one for the RectangleClient class and 2 .class files associated with these .java files. So in total you will be submitting 4 files for part b of this assignment.) // A Rectangle stores an (x, y) coordinate...
Create a class called Retangle.java that contains two double-precision instance variables named width and height. The class should include all kinds of overloaded constructors. Additionally, there should be two accessor methods, mutator methods, class method named area() that returns the area of a Rectangle object. Inside main(),fully test all methods.
In a project named 'DogApplication', create a class called 'Dog' 1. declare two instance variables in 'Dog' : name (String type) age (int type) 2. declare the constructor for the 'Dog' class that takes two input parameters and uses these input parameters to initialize the instance variables 3. create another class called 'Driver' and inside the main method, declare two variables of type 'Dog' and call them 'myDog' and 'yourDog', then assign two variables to two instance of 'Dog' with...