Answer :

Answer:

Following are the expression in the Java language

public class Main

{

public static void main(String[] args) // Main method

{

boolean young= true; // variable declaration

boolean famous= true;// variable declaration

if(young && famous) // check the condition

System.out.println("You must be rich  "  );// display message

}

}

Output:

You must be rich

Explanation:

Following are the description of the above statement

  • Declared a variable "young " of the boolean type that is initialized with the "true" value.
  • Declared a variable "famous " of  the boolean type that is initialized with the "true" value.
  • Check the condition of if() block.If the condition is true then it executed the condition inside the if block.
  • Finally ,print the message  "You must be rich!"

Answer:

young = (input() == 'True')

famous = (input() == 'True')

if (young == True) and (famous == True):

   print('You must be rich!')

else:

   print('There is always the lottery...')

Explanation:

It will ask the user to put true or false for being young and famous.  If both are True it will give out "You must be rich!"  If either are False it will give the output "There is always the lottery...

Other Questions