Computer Science, asked by anuhansda2001, 3 months ago

write a program in java to find the area of reactangle ​

Answers

Answered by matteodagostino
0

import java.util.Scanner; // Imports the Scanner class to ask user for input

public class AreaOfRectangle {

public static void main(String[] args) {

 Scanner input = new Scanner(System.in); // Creates a scanner called "input"

 System.out.print("Enter the height of the rectangle in centimetres: "); // Asks the user for the height of the rectangle

 double height = input.nextDouble(); // Stores the user's answer in a variable called height

 System.out.print("Enter the width of the rectangle in centimetres: "); // Asks the user for the width of the rectangle

 double width = input.nextDouble(); // Stores the user's answer in a variable called width

 double area; // Creates variable called area which will store the final answer

 area = (height * width); // Finds the area of the rectangle

 System.out.println("The area of the rectangle is " + area + " cm^2"); // Prints the answer

}

}

Answered by lavleenkaur2009
0

Answer:

If u like my answer Pls mark me as brainliest

Attachments:
Similar questions