Question

Java Using NetBean Design a math method rectArea to calculate rectangle area = width * height....

Java Using NetBean

Design a math method rectArea to calculate rectangle area = width * height. Your main program will get width and height from user and call rectArea for calculation and then the main program will show the final result.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner in=new Scanner(System.in);
System.out.println("Enter height: ");
int h=in.nextInt();
System.out.println("Enter widh: ");
int w=in.nextInt();
System.out.println("Area: "+rectArea(h,w));
  
}
public static double rectArea(int width,int height)
{
return width*height;
}
}

Add a comment
Know the answer?
Add Answer to:
Java Using NetBean Design a math method rectArea to calculate rectangle area = width * height....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA design a class named Rectangle to represent a rectangle. The class contains: A method named getPerimeter() that returns the perimeter. Two double data fields named width and height that specify...

    JAVA design a class named Rectangle to represent a rectangle. The class contains: A method named getPerimeter() that returns the perimeter. Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height. A no-arg constructor that creates a default rectangle. A constructor that creates a rectangle with the specified width and height. A method named getArea() that returns the area of this rectangle. design...

  • #1 Write a java program which calculates the area of either a Triangle or a Rectangle....

    #1 Write a java program which calculates the area of either a Triangle or a Rectangle. Use Scanner to take an input field to tell you if the area to be calculated is for a Triangle or is for a Rectangle. Depending on that input - the program must call either the Triangle method or the Rectangle method. Each of those methods must receive 2 input fields from the user - one for base and one for height in order...

  • In Java Exercise #2: (Java) Design and implement a program (name it ComputeAreas) that defines four...

    In Java Exercise #2: (Java) Design and implement a program (name it ComputeAreas) that defines four methods as follows: Method squareArea (double side) returns the area of a square. Method rectangleArea (double width, double length) returns the area of a rectangle. Method circleArea (double radius) returns the area of a circle. Method triangleArea (double base, double height) returns the area of a triangle. In the main method, test all methods with different input value read from the user. Document your...

  • Area Program – Build a Java Class to Calculate the area of a Figure(call it “Area.java”....

    Area Program – Build a Java Class to Calculate the area of a Figure(call it “Area.java”. The figure may be a circle, or a square or a rectangle. The user will enter the type of figure they want through a Scanner. If they enter a “C”, proceed to calculate the area of the Circle using values read in for radius. If they enter an “S”, then calculate the area of a Square using values read in for side. If they...

  • Java Using NetBean Given a cylinder with radius of 5 and height of 8, write a...

    Java Using NetBean Given a cylinder with radius of 5 and height of 8, write a program to calculate the volume of this cylinder. You need to define a constant value PI in your program.

  • Write a java method to calculate the area of a kite using the following formula: area...

    Write a java method to calculate the area of a kite using the following formula: area = (length x height ) /2 The method return a double value to main for the area and receives no parameters. public static double area () the method will prompt the user to enter a value for length and height, will calculate the area and then returns the value of area to main. Main will display this value to user.

  • Write a Java program with the following requirements: Rectangle that implements Shape2D - instance variables height,...

    Write a Java program with the following requirements: Rectangle that implements Shape2D - instance variables height, width Block that implements Shape3D - instance variables height, width, depth Add appropriate parameterized constructors for each class. Implement the abstract methods to make each class a Shape2D, Shape3D, or both. Make the main method use each of these to print out the area of a rectangle, and the area and volume of a block.

  • Java Instructions of assignment: Inside 1st class - Find the int width and height of a...

    Java Instructions of assignment: Inside 1st class - Find the int width and height of a rectangle; include methods to set and get the width and height; and a method to calculate and return the area Inside 2nd class - Use an ArrayList to store 10 unique dimensions of the rectangle class - Set the width & height using a constructor or setter methods - Create a bubble sort algorithm list inside a method to set the areas in descending...

  • Calculate the area of a rectangle. -          Utilize at least three functions, “Get Input” – “Calculation” –...

    Calculate the area of a rectangle. -          Utilize at least three functions, “Get Input” – “Calculation” – “Show Output” -          The “Get Input” function must use call-by-reference parameters to gather data -          The program must ask the user if they would like to run it again This is a C++ Project using call by reference. If possible please make it as simple as possible as i'm already very confused the way it is.

  • JAVA Code Requried Copy the file java included below. This program will compile, but, when you...

    JAVA Code Requried Copy the file java included below. This program will compile, but, when you run it, it doesn’t appear to do anything except wait. That is because it is waiting for user input, but the user doesn’t have the menu to choose from yet. We will need to create this. Below the main method, but in the Geometry class, create a static method called printMenu that has no parameter list and does not return a value. It will...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT