fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. import java.util.Scanner;
  9. class GeometryCalculator{
  10. public static void main(String[] args) {
  11. Scanner user_input = new Scanner(System.in);
  12. System.out.println("Enter width: ");
  13. int width = user_input.nextInt();
  14. System.out.print(width);
  15. System.out.println("Enter height: ");
  16. int height = user_input.nextInt();
  17. System.out.print(height);
  18.  
  19. int area = width*height;
  20. int perimeter = (2*width) + (2*height);
  21. System.out.println("Area is " + area + "square inches.");
  22. System.out.println("Perimeter is " + perimeter + "inches.");
  23. }
  24. }
Success #stdin #stdout 0.15s 60652KB
stdin
10 8
stdout
Enter width: 
10Enter height: 
8Area is 80square inches.
Perimeter is 36inches.