126k views
1 vote
Write an expression that prints 'You must be rich!' if the variables young and famous are both True. Sample output with inputs: 'True' 'True' You must be rich!

User CuberChase
by
3.0k points

2 Answers

4 votes

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...')

Step-by-step 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...

User Antonis Zisis
by
4.1k points
3 votes

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

Step-by-step 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!"
User Siggy
by
3.8k points