Write a java program to create a class named shape. In this class we have two sub classes circle and square.
//class Shape
class Shape
{
void getInput()
{
}
void calculateArea()
{
}
}
//class Circle
class Circle extends Shape
{
public int r;
public double pi = 3.14;
double area;
public void getInput(int radius)
{
r = radius;
}
//method to calculate area
public void calculateArea()
{
area = pi * r * r;
System.out.println("Area of the circle: "+area);
}
}
//clase square
class Square extends Shape
{
int s;
double area;
public void getInput(int side)
{
s = side;
}
//method to calculate area
public void calculateArea()
{
area = s * s;
System.out.println("Area of the rectangle: "+ area);
}
}
public class Main
{
public static void main(String[] args)
{
//create class object
Circle cir = new Circle();
//call method
cir.getInput(10);
cir.calculateArea();
//create Square class object
Square rec = new Square();
//call method
rec.getInput(10);
rec.calculateArea();
}
}
OUTPUT:

Write a java program to create a class named shape. In this class we have two...
Using Python Write the following well-documented (commented) program. Create a class called Shape that has a method for printing the area and the perimeter. Create three classes (Square, Rectangle, and Circle) which inherit from it. Square will have one instance variable for the length. Rectangle will have two instance variables for the width and height. Circle will have one instance variable for the radius. The three classes will have methods for computing the area and perimeter of its corresponding shape....
Please help we write a java program for this
Write a class for a single Card from a Deck of Cards. Think about what you'll need to store in a single card to identify it from the rest. Create a second class to represent the deck. Create a test program to create a complete deck of cards. Draw a UML diagram for your two classes.
Write a complete Java program with OO classes The code should have: A super class named Home Properties address SF (this is the number of Square feet) value (this is the dollar value of the home) PPSF (price per square foot) you will calculate this in a method Methods Set and get methods for all properties CalcPPSF - (PPSF is the value/SF) A sub class named Condo, which has one more HOA property: Property: HOAfee (home owners association fee) Methods...
Write a complete Java program to do the following Your code should have: A super class named Home Properties address SF (this is the number of Square feet) value (this is the dollar value of the home) PPSF (price per square foot) you will calculate this in a method Methods Set and get methods for all properties CalcPPSF - (PPSF is the value/SF) A sub class named Condo, which has one more HOA property: Property: HOAfee (home owners association fee)...
Write a java program that creates two interfaces named test1 and test2. In interface test1 the member function is square. In interface test2 the member function is cube. Implement these two interfaces in "Arithmetic" class. Create one new class called ToTestInt in this class use the object of arithmetic class.
Can some please help me to answer these two questions. Write a program in Java create a class diagram fragment with two classes: User and Patient. Patient is a sub-class of User. User has a method getName(), which is both over-loaded and over-ridden in the subclass In Java write an abstract class called User. User has one abstract method called authenticate, which takes two string parameters. Write a concrete sub-class of User called Administrator with an implementation of the authenticate...
Create a program that calculates the area of various shapes.
Console
Specifications
Create an abstract class named Shape. This
class should contain virtual member function named
get_area() that returns a double type.
Create a class named Circle that inherits the
Shape class and contains these constructors and member functions:
Circle(double radius)
double get_radius()
void set_radius(double radius)
double get_area()
Create a class named Square that inherits the
Shape class and contains these constructors and member functions:
Square(double width)
double get_width()
void...
write C++ program Create a class named Bicycle with one public pure virtual function showFeatures(). Create the two classes MountainBike and BeachCruiser that both publicly inherit from Bicycle. Please add necessary member variables and functions to each class. The showFeatures() function shows the details about a bicycle. should have main.cpp Bicycle.h Bicycle.cpp MountainBike .h MountainBike.cpp BeachCruiser.h BeachCruiser.cpp
write a java program to create the class and object to compare to two rational number to check if they are equal or not (we didn't learn reduce() and this. can you solve it without using these things?)
Implement the Shape hierarchy -- create an abstract class called Shape, which will be the parent class to TwoDimensionalShape and ThreeDimensionalShape. The classes Circle, Square, and Triangle should inherit from TwoDimensionalShape, while Sphere, Cube, and Tetrahedron should inherit from ThreeDimensionalShape. Each TwoDimensionalShape should have the methods getArea() and getPerimeter(), which calculate the area and perimeter of the shape, respectively. Every ThreeDimensionalShape should have the methods getArea() and getVolume(), which respectively calculate the surface area and volume of the shape. Every...