{"id":1415,"date":"2022-03-03T19:36:05","date_gmt":"2022-03-03T19:36:05","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1415"},"modified":"2022-03-03T19:36:05","modified_gmt":"2022-03-03T19:36:05","slug":"program-to-calculate-area-of-rectangle","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/03\/03\/program-to-calculate-area-of-rectangle\/","title":{"rendered":"Program to Calculate Area of Rectangle"},"content":{"rendered":"\n<p>In this tutorial we will see how to&nbsp;<strong>calculate Area of Rectangle<\/strong>.<\/p>\n\n\n\n<p><strong>Program 1:<\/strong><br>User would provide the length and width values during execution of the program and the area would be calculated based on the provided values.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @author: BeginnersBook.com\n * @description: Program to Calculate Area of rectangle\n *\/\nimport java.util.Scanner;\nclass AreaOfRectangle {\n   public static void main (String&#91;] args)\n   {\n\t   Scanner scanner = new Scanner(System.in);\n\t   System.out.println(\"Enter the length of Rectangle:\");\n\t   double length = scanner.nextDouble();\n\t   System.out.println(\"Enter the width of Rectangle:\");\n\t   double width = scanner.nextDouble();\n\t   \/\/Area = length*width;\n\t   double area = length*width;\n\t   System.out.println(\"Area of Rectangle is:\"+area);\n   }\n}<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter the length of Rectangle:\n2\nEnter the width of Rectangle:\n8\nArea of Rectangle is:16.0<\/code><\/pre>\n\n\n\n<p><strong>Program 2:<\/strong><br>In the above program, user would be asked to provide the length and width values. If you do not need user interaction and simply want to specify the values in program, refer the below program.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @author: BeginnersBook.com\n * @description: Calculation with no user interaction\n *\/\nclass AreaOfRectangle2 {\n   public static void main (String&#91;] args)\n   {\n\t   double length = 4.5;\n\t   double width = 8.0;\n\t   double area = length*width;\n\t   System.out.println(\"Area of Rectangle is:\"+area);\n   }\n}<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Area of Rectangle is:36.0<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial we will see how to&nbsp;calculate Area of Rectangle. Program 1:User would provide the length and width values during execution of the program and the area would be calculated based on the provided values. Output: Program 2:In the above program, user would be asked to provide the length and width values. If you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[570],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1415"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=1415"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1415\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1415"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1415"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1415"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}