Advertisement
VadimThink

Laba1_1 Java

Sep 8th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. package com.laba1_1;
  2.  
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class Main {
  7.  
  8.     public static void main(String[] args) {
  9.         Scanner in = new Scanner(System.in);
  10.         boolean isCorrect = false;
  11.         int iRad = 0;
  12.         int iSquare = 0;
  13.         System.out.println("Тема: Пройдет ли круг в квадрат?");
  14.         do {
  15.             System.out.println("Введите радиус круга от 1 до 150 ");
  16.             if (in.hasNextInt()) {
  17.                 iRad = in.nextInt();
  18.                 isCorrect = true;
  19.             } else {
  20.                 in.nextLine();
  21.                 System.out.println("Введите реальное значение");
  22.             }
  23.         }
  24.         while (!isCorrect);
  25.         isCorrect = false;
  26.         do {
  27.             System.out.println("Введите сторону квадрата от 1 до 150 ");
  28.             if (in.hasNextInt()) {
  29.                 iSquare = in.nextInt();
  30.                 isCorrect = true;
  31.             } else {
  32.                 in.nextLine();
  33.                 System.out.println("Введите реальное значение");
  34.             }
  35.         }
  36.         while (!isCorrect);
  37.         if ((iSquare / 2) > iRad) {
  38.             System.out.println("Проходит");
  39.         }
  40.         else {
  41.             System.out.println("Не проходит");
  42.         }
  43.  
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement