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 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...
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....
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).
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?
JAVA program: Calculate geometric area for 3 shapes(square, rectangle and circle). You need to build a...
JAVA program: Calculate geometric area for 3 shapes(square, rectangle and circle). 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 Invalid input should throw a message for the user. Example: Invalid input, please try again Each options should ask users for relevant data. HINT: use scanner object to take in length for square,...
1. The amount of discount is determined by multiplying the invoice total (after any returns and...
1. The amount of discount is determined by multiplying the invoice total (after any returns and allowances and freight charges have been deducted) by the cash discount rate. For the following purchases of merchandise, determine the amount of cash to be paid. If required, round your answers to the nearest cent. Purchase Invoice Date Credit Terms FOB Amount of Purchase Freight Charges Total Invoice Amount Returns and Allowances Date Paid Amount of cash to be paid a. 7/7/13 2/10, n/30...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT