import java.util.*;
public class Main
{
static int calculateArea(int l,int b)
{
//methods takes length and width and
//returns area
return l*b;
}
public static void main(String[] args) {
int length,width;
Scanner s=new
Scanner(System.in);
//read length and widths
System.out.print("enter length of
rectangle:");
length=s.nextInt();
System.out.print("enter width of
rectangle:");
width=s.nextInt();
//call function
int
area=calculateArea(length,width);
System.out.println("The Area of
rectangle is "+area);
}
}
i need a simple java program that uses methods to find the area of 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...
part A) using java methods calculate the area of rectangle. part B) modify to calculate the area of rectangle, circle, triangle and square this time using switch statement, input validation, loop for choices and document the program.
Write a Java program that prompts user to select one of the five shapes(Rectangle, Square, Triangle, Circle, and Parallelogram), then calculate area of the shape,must have input validation and uses more of java library like math class, wrapper class, string methods, use formatted output with the printf method. Finally, create a pseudo-code statement and flowchart
Write a Java application to find the area of 1) rectangle 2) Triangle 3) Circle using runtime polymorphism concept. Shape Area rectangle length*width Triangle 0.5*length*width Circle PI*radius*radius. I am confused as to what polymorphism is and would really appreciate some help. This is in Java as well.
Description Create an object-oriented program that uses inheritance to perform calculations on a rectangle or a square. Sample Output (Your output should be similar to the text in the following box) Rectangle Calculator Rectangle or square? (r/s): r Height: 5 Width: 10 Perimeter: 30 Area: 50 Continue? (y/n): y Rectangle or square? (r/s): s Length: 5 Perimeter: 20 Area: 25 Continue? (y/n): n Thank you for using my app Specifications Use a Rectangle class that provides attributes to store the...
Java simple problem I need to make a program that will press CTR + ALT + F1 key automatic ly when it been called.
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.
Following is my java program that i need help with. Write a program that uses a JavaFX GUI that allows a user to enter a directory (folder) and then displays the number of the files in the directory. The number of files in the directory should be determined recursively.
Go to the Java API and review the Rectangle class briefly. As directed below, create a subclass of the Rectangle class called BetterRectangle as described below. Create another class called RectangleTester, which fully tests the BetterRectangle, by displaying a menu that allows a user to process data for multiple rectangles until they choose to quit. Be sure to include sample runs as block comments in your tester source code file. P9.10 The Rectangle class of the standard Java library does...
Write a Java program to find the perimeter of rectangle and ask the user to input length and width.