Advertisement
dimipan80

Rectangle Area

Aug 17th, 2014
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.68 KB | None | 0 0
  1. /* Write a program that enters the sides of a rectangle (two integers a and b)
  2.  * and calculates and prints the rectangle's area. */
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class _01_RectangleArea {
  7.  
  8.     public static void main(String[] args) {
  9.         // TODO Auto-generated method stub
  10.         Scanner scan = new Scanner(System.in);
  11.         System.out.println("Enter 2 positive Integer numbers for the sides of rectangle:");
  12.         int sideA = scan.nextInt();
  13.         int sideB = scan.nextInt();
  14.  
  15.         if (sideA > 0 && sideB > 0) {
  16.             long rectangleArea = sideA * sideB;
  17.             System.out.println("The Area of that rectangle is: " + rectangleArea);
  18.         } else {
  19.             System.out.println("Error! - Invalid Input!!!");
  20.         }
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement