Friday 6 February 2015

We have two monkeys, a and b, and the parameters aSmile and bSmile indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling. Return true if we are in trouble. monkeyTrouble(true, true) → true monkeyTrouble(false, false) → true monkeyTrouble(true, false) → false

Q:1 



We have two monkeys, a and b, and the parameters aSmile and bSmile indicate if each is smiling. We are in trouble if they are both smiling or if neither of them is smiling. Return true if we are in trouble.

monkeyTrouble(true, true) → true
monkeyTrouble(false, false) → true
monkeyTrouble(true, false) → false

















 import java.util.Scanner;
class Test
{
public static void main(String [] args)
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter bollean value for aSmile= ");
boolean aSmile=sc.nextBoolean();
System.out.print("Enetr only booblean value for bSmile=  ");
boolean bSmile=sc.nextBoolean();
if(aSmile && bSmile || !aSmile && !bSmile)
{
System.out.println("true");
}
else
{
System.out.println("false");
}
}
}

No comments:

Post a Comment