Ask Question
7 August, 16:27

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!

+5
Answers (1)
  1. 7 August, 19:51
    0
    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!"
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Write an expression that prints 'You must be rich!' if the variables young and famous are both True. Sample output with inputs: 'True' ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers