answersLogoWhite

0


Best Answer

Remember that the area of a rectangle is width * height:

static int getArea(Rectangle r) {

return r.width * r.height;

}

User Avatar

Wiki User

14y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

write a program in java to calculate the area of rectangle with two classes

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a menu driven program in java to find area of different shapes. 1. Circle 2. Triangle 3. Rectangle?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are some examples of simple geometric shapes?

square triangle circle oval rectangle polygon


Write various ways to implement stack data structure?

2. Write a program using switch statement that reads a character representing a geometrical figure, then asks the user to enter the required data (ex. Radius for a circle, length and height for a rectangle, etc. ...) . The program should then print the area and circumference.Figures are: circle(c), square(s), rectangle(r), triangle (t).


How do you find an area of a shape rectangle square and a circle in C program?

By using that one thing.


How do you create triangle circle and rectangle classes derived from a base class shape with virtual area function in c plus plus?

#include<iostream> struct shape { virtual double area () const = 0; }; struct triangle : shape { triangle (double b, double h): base (b), height (h) {} double base, height; double area () const override { return base * height / 2; } }; struct circle : shape { circle (double r): radius (r) {} double radius; double area () const override { return 4 * atan(1) * radius * radius; } }; struct rectangle : shape { rectangle (double w, double h): width (w), height (h) {} double width, height; double area () const override { return width * height; } }; int main() { triangle t (10, 5); std::cout << "triangle with base " << t.base << " and height " << t.height << " has area " << t.area() << std::endl; circle c (5); std::cout << "circle with radius " << c.radius << " has area " << c.area() << std::endl; rectangle r (10, 5); std::cout << "rectangle with width " << r.width << " and height " << r.height << " has area " << r.area() << std::endl; }


How do you write a qbasic program to find area and circumerence of a circle?

Write a program that calculates the area of a triangle in QBASIC