A simple calculator for a rectangle's area. The formula for finding the area of a rectangle is width x height. The user will be asked to input the width and the height.
import java.util.Scanner;
public class TriAreaCalc {
public static void main(String[] args) {
double width;
double height;
Scanner reader=new Scanner(System.in);
System.out.println("Enter width: ");
width=reader.nextDouble();
System.out.println("Enter height: ");
height=reader.nextDouble();
double area=width*height;
System.out.println("The area of the triangle is " +area);
}
}
import java.util.Scanner;
public class TriAreaCalc {
public static void main(String[] args) {
double width;
double height;
Scanner reader=new Scanner(System.in);
System.out.println("Enter width: ");
width=reader.nextDouble();
System.out.println("Enter height: ");
height=reader.nextDouble();
double area=width*height;
System.out.println("The area of the triangle is " +area);
}
}
Here's the output:
Comments
Post a Comment