Computer Science, asked by kingmudashir, 7 months ago

Write a java program to enter the length and breadth of a rectangle and print its

area and the length of its diagonal.​

Answers

Answered by archismitaj
1

Answer:

)

1

import java.util.Scanner;

– Syntax, which read the input values, in simple words, it’s an inbuilt package.

2)

1

class AreaOfRectangle

– A class is a blueprint, where objects are created.

3)

1

public static void main(String args[])

– And, the program starts executing from here, the main head of the block program starts here.

4)

1

Scanner s= new Scanner(System.in);

– scanner, which reads the input values, and system.in uses to retrieve the data from the JDK package from your system or device.

5)

1

System.out.println("Enter the length:");

– Displays, whatever you were written on that syntax, followed by second.

6)

1

double l= s.nextDouble();

– Double, A memory space where the user can give the values either in decimal points or without decimal points. Since we are using the ” Double “. Double can store the values up to 8 bytes, and the name os the memory is L. Consider it has same to ” B “.

7)

1.

double area=l*b;

– The formula to find out the area of the rectangle.

8)

1

System.out.println("Area of Triangle is: " + area);

– Output displayed here.

We always make sure to write the java program in a simple way to the users and newbies can able to understand the program better. Lengthy codes are way better too, but those extra couple of code lines are actually not necessary.

Here is another simple method to find out the area of a rectangle, the below program is quite simple.

Similar questions