Area solver for shapes is just one of the exercises given by most programming instructors. Some other exercises are the following:

1. Celsius to Fahrenheit Temperature Converter

2. Identify if odd or even number

3. Display numbers using a for loop

4. Solve for the area of a triangle

5. Fibonacci Series

Area is the size of the surface of an object. In this article, we will discuss about the formula and

**java code**in solving for the

**area of a rectangle**.

This program will allow a user to input the desired height and width and will solve for the

**area**of the given

**rectangle**.

**Formula Area of Rectangle**

A = area of the rectangle

w = width

h = height

**Java Code Area of Rectangle**

import java.util.Scanner;

public class Rectangle{

public static void main(String[] args) {

// solve for the area of a rectangle

Scanner console=new Scanner(System.in);

System.out.println("Enter width: ");

double width = console.nextDouble();

System.out.println("Enter height: ");

double height = console.nextDouble();

double area=width*height;

System.out.printf("The area of a rectangle is %.2f",area);

}

}

**Output**

Thank you for visiting and hope this helps you. Feel free to leave a comment below for any questions. I got some other articles related to php and mysql here in my blog. Watch out for more upcoming tutorials related to blogging and programming. Good day! ^_^

## No comments:

## Post a Comment