Advertisement
Valik888

OOP_1

Mar 11th, 2015
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. package practice1;
  2.  
  3. /**
  4.  *
  5.  * @author valik888
  6.  */
  7. import java.io.*;
  8. import java.util.*;
  9.  
  10. public class mainClass {
  11.     public static void main(String[] args) throws IOException {
  12.       System.out.println("Введите сторону квадрата: ");
  13.       double a, answer;
  14.       BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  15.       Scanner sc = new Scanner(System.in);
  16.       /* double a = Double.parseDouble(sc.nextDouble()); */
  17.       String str = bf.readLine();
  18.       a = Double.parseDouble(str);
  19.       if(a <=0 ){
  20.           System.out.println("Ошибка ввода!");
  21.       } else {
  22.           answer = a * a;
  23.           System.out.println("Площадь квадрата равна: " + answer);
  24.       }
  25.      
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement