Ask Question

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!

+4
Answers (1)
  1. 14 March, 04:10
    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 & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers