Advertisement
cgorrillaha

Intro Java Areas

Sep 18th, 2020
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. class Main {
  2.   public static void main(String[] args) {
  3.     /*
  4.     can support decimal values: float and double
  5.     integer types: byte short int long
  6.     */
  7.  
  8.     //declaring variables
  9.     double areaOfCircle;
  10.     int areaOfRect;
  11.  
  12.     int length, width, radius;
  13.     final double PI=Math.PI;
  14.  
  15.     //inputs
  16.     length=15;
  17.     width=24;
  18.     radius=5;
  19.  
  20.     //calcs
  21.     areaOfRect=length*width;
  22.     areaOfCircle=radius*radius*PI;
  23.     areaOfCircle=Math.pow(radius,2)*PI;
  24.  
  25.     //outputs
  26.     System.out.println("Area of a rectangle with length: "+length+
  27.                         " and a witdth: "+width+ " is: "+areaOfRect);
  28.   }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement