Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ParrotProblem
- {
- public boolean pProblem(int hr, boolean is_Talking ){
- return ( ( (hr >= 20 && hr < 24) || ( hr < 7 && hr >= 0 ) ) && is_Talking );
- }
- public static void main(String args[]){
- Scanner sc = new Scanner(System.in);
- ParrotProblem ob1 = new ParrotProblem();
- System.out.println("Is the parrot talking?(Y/N)");
- boolean is_Talking = sc.nextLine().equals( "Y" ) ? true : false;
- System.out.println("Enter the hour according to 24 hrs clock");
- int hr = sc.nextInt();
- System.out.println( ob1.pProblem( hr, is_Talking) ? "Problem" : "No problem");
- }
- }
Add Comment
Please, Sign In to add comment