KAKAN

Parrot Problem

Dec 6th, 2017
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class ParrotProblem
  3. {
  4.     public boolean pProblem(int hr, boolean is_Talking ){
  5.         return ( ( (hr >= 20 && hr < 24) || ( hr < 7 && hr >= 0 ) ) && is_Talking );
  6.     }
  7.     public static void main(String args[]){
  8.         Scanner sc = new Scanner(System.in);
  9.         ParrotProblem ob1 = new ParrotProblem();
  10.         System.out.println("Is the parrot talking?(Y/N)");
  11.         boolean is_Talking = sc.nextLine().equals( "Y" ) ? true : false;
  12.         System.out.println("Enter the hour according to 24 hrs clock");
  13.         int hr = sc.nextInt();
  14.         System.out.println( ob1.pProblem( hr, is_Talking) ? "Problem" : "No problem");
  15.     }
  16. }
Add Comment
Please, Sign In to add comment