The following code shows A Java Program to Compute and Display Area of a Rectangle.
// Create a simple program to find out area of a rectangle
import java.io.*;
class Rectangle
{
int length, breadth;
public void getDimensions() throws IOException
{
System.out.println("Enter the length of rectangle...");
BufferedReader mybuffer=new BufferedReader(new InputStreamReader(System.in));
length=Integer.parseInt(mybuffer.readLine());
System.out.println("\nEnter the breadth of rectangle...");
mybuffer=new BufferedReader(new InputStreamReader(System.in));
breadth=Integer.parseInt(mybuffer.readLine());
}
public void findArea()
{
System.out.println("\nArea of the rectangle comes out to be "+(length*breadth)+" Units!");
}
}
public class Main
{
public static void main(String[] args) throws IOException {
Rectangle rectOb=new Rectangle();
rectOb.getDimensions();
rectOb.findArea();
}
}
Output
Further Reading
Understanding Enterprise Java Beans
- AI
- Android
- Angular
- ASP.NET
- Augmented Reality
- AWS
- Bioinformatics
- Biometrics
- Blockchain
- Bootstrap
- C
- C#
- C++
- Cloud Computing
- Competitions
- Courses
- CSS
- Cyber Security
- Data Science
- Data Structures and Algorithms
- Data Visualization
- Datafication
- Deep Learning
- DevOps
- Digital Forensic
- Digital Trust
- Digital Twins
- Django
- Docker
- Dot Net Framework
- Drones
- Elasticsearch
- ES6
- Extended Reality
- Flutter and Dart
- Full Stack Development
- Git
- Go
- HTML
- Image Processing
- IoT
- IT
- Java
- JavaScript
- Kotlin
- Latex
- Machine Learning
- MEAN Stack
- MERN Stack
- Microservices
- MongoDB
- NodeJS
- PHP
- Power Bi
- Projects
- Python
- Quantum Computing
- React
- Robotics
- Rust
- Scratch 3.0
- Shell Script
- Smart City
- Software
- Solidity
- SQL
- SQLite
- Tecgnology
- Tkinter
- TypeScript
- VB.NET
- Virtual Reality
- Web Designing
- WebAssembly
- XML