Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main
- {
- public static void main(String[]args)
- {
- int radius = 0, side = 0;
- Scanner in = new Scanner(System.in);
- boolean IsCorrect;
- System.out.print("The program will determine whether the circle fits into the
- square.\n");
- System.out.print("Enter radius: ");
- do
- {
- IsCorrect = false;
- try {
- radius = Integer.parseInt(in.next());
- }
- catch (NumberFormatException e) {
- System.out.print("Incorrect value. Enter the number: ");
- IsCorrect = true;
- }
- if ((!IsCorrect) && (radius == 0) || (radius < 0))
- {
- System.out.print("Incorrect value. Enter the number: ");
- IsCorrect = true;
- }
- } while (IsCorrect);
- System.out.print("Enter side: ");
- do
- {
- IsCorrect = false;
- try {
- side = Integer.parseInt(in.next());
- }
- catch (NumberFormatException e) {
- System.out.print("Incorrect value. Enter the number: ");
- IsCorrect = true;
- }
- if ((!IsCorrect) && (side == 0) || (side < 0))
- {
- System.out.print("Incorrect value. Enter the number: ");
- IsCorrect = true;
- }
- } while (IsCorrect);
- in.close();
- if (radius * 2 < side)
- System.out.print("Fit in.\n");
- else
- System.out.print("Not fit in.\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement