Question

In: Computer Science

Q 1 - The surface area of a square or rectangle can be determined by multiplying...

Q 1 - The surface area of a square or rectangle can be determined by multiplying the length by the breadth. In a method called GetArea(), write a Java program to determine the surface area of a given square or rectangle. Assume the measurements will be in metres. The program should prompt the user for length and breadth values. [15]

Input
None
Output
Given a rectangle with length 20 metres and breadth 15 metres, the output would be: 300 square metres

Solutions

Expert Solution

import java.util.Scanner;
public class area {

   public static void main(String[] args) {
       Scanner in=new Scanner(System.in);
       //user input
       System.out.println("Enter length: ");
       double length=in.nextDouble();
      
       System.out.println("Enter width: ");
       double width=in.nextDouble();
       //print area
       System.out.println("Surface area is: "+GetArea(length,width)+" square meter");

   }
   //method
   public static double GetArea(double length,double width)
   {
       return length*width;//return area
   }

}


Related Solutions

The area of a particular rectangle is 12 times the area of a certain square, and...
The area of a particular rectangle is 12 times the area of a certain square, and the width of the rectangle is three times the length of a side of the square. The perimeter of the rectangle is 30 units greater than the perimeter of the square. Find the dimensiuons of both the rectangle and the square.
The following program supposes to calculate the area of a rectangle and square. Then, produce the...
The following program supposes to calculate the area of a rectangle and square. Then, produce the following output. Area of Rectangle: 50 Unfortunately, the program has compile-time and run-time errors that prevent the program from running and producing the correct result. Using table 3.1 below, allocate the error(s) on each program line. 1 public class RectangleArea {   2   Public static void main() {   3     int width == 10; 4     int height = 5; 5     int recArea = width + height; 6      System.Out.print(Area of Rectangle:); 7      System.out.println(“recArea”)...
The rectangle below is made up of 12 squares of the same size. Find the perimeter of the rectangle if the area of the rectangle is equal to 1728 square cm.
The rectangle below is made up of 12 squares of the same size. Find the perimeter of the rectangle if the area of the rectangle is equal to 1728 square cm.
Write a program to calculate the area of four shapes (Rectangle, triangle, circle and square). The...
Write a program to calculate the area of four shapes (Rectangle, triangle, circle and square). The program to present the user with a menu where one of the shapes can be selected. Based on the selection made, the user enters the proper input, the program validates the input (i.e all entries must be greater than zero). Once the input is entered and validated, the intended area is calculated and the entered information along with the area are displayed. Area of...
a. Explain how the catchment area is determined when calculating surface runoff. b. How can the...
a. Explain how the catchment area is determined when calculating surface runoff. b. How can the adverse effects of urban development on downstream runoff be minimized? Name the principles and discuss.
Q No# 8 How is the maximum basic floor area of a building determined? Q No#...
Q No# 8 How is the maximum basic floor area of a building determined? Q No# 11 How are the exterior wall fire-resistance rating requirements determined for buildings that are on the same lot? Q No# 15 How are the required fire-resistance ratings of specific building elements determined? Q No# 16 How do the two different categories of Type I construction differ in fire protection? Q No# 17 Which characteristics are typical of a Group I occupancy? Q No# 18...
Base class: Polygon Derived classes: Rectangle, Triangle Make Square a derived class of Rectangle. There can...
Base class: Polygon Derived classes: Rectangle, Triangle Make Square a derived class of Rectangle. There can be several ways to represent the shapes. For example, a shape can be represented by an array of side lengths counted in the clock-wise order. For example, {2, 4, 2, 4} for a rectangle of width 2 and height 4, and {4, 4, 4, 4} for a square. You need to design your representation. Each polygon should have a function area() that returns its...
What is the minimum surface area of a box whose top and bottom is a square...
What is the minimum surface area of a box whose top and bottom is a square if the volume is 40 cubic inches. (Surface area is the area of all the sides of the box).
REQUIREMENTS OF THE JAVA PROGRAM: Your task is to calculate geometric area for 3 shapes(square, rectangle...
REQUIREMENTS OF THE JAVA PROGRAM: Your task is to calculate geometric area for 3 shapes(square, rectangle and circle). 1. You need to build a menu that allows users to enter options. Possible options are 'S' for square, 'R' for rectangle and 'C' for circle. HINT: you can use switch statement to switch on string input a. Invalid input should throw a message for the user. Example: Invalid input, please try again 2. Each options should ask users for relevant data....
How can I prove that the angle bisectors of a rectangle form a square?
How can I prove that the angle bisectors of a rectangle form a square?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT