Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- /*
- can support decimal values: float and double
- integer types: byte short int long
- */
- //declaring variables
- Scanner scan;
- double areaOfCircle;
- int areaOfRect;
- int length, width, radius;
- final double PI=Math.PI;
- //inputs
- scan=new Scanner(System.in);
- length=15;
- width=24;
- radius=5;
- //prompt for length and width
- System.out.println("Please enter the length of the rectangle");
- //input using Scanner
- length=scan.nextInt();
- System.out.println("Please enter the width of the rectangle");
- //input using Scanner
- width=scan.nextInt();
- System.out.println("Please enter the radius of the circle");
- //input using Scanner
- radius=scan.nextInt();
- //calcs
- areaOfRect=length*width;
- areaOfCircle=radius*radius*PI;
- areaOfCircle=Math.pow(radius,2)*PI;
- //outputs
- System.out.println("Area of a rectangle with length: "+length+
- " and a witdth: "+width+ " is: "+areaOfRect);
- System.out.println("Area of a circle with radius: "+radius+
- " is: "+areaOfCircle);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement