Ask Question
4 February, 07:08

Given two variables, is Empty of type boolean, indicating whether a class roster is empty or not, and number Of Credits of type int, containing the number of credits for a class, write an expression that evaluates to true if the class roster is empty or the class is exactly three credits.

+5
Answers (1)
  1. 4 February, 07:26
    0
    if (isEmpty || numOfCredits==3) {

    }

    Explanation:

    Consider a complete java program below that prompts user for number of credits and also asks if class roster is empty or not

    import java. util. Scanner;

    public class num13 {

    public static void main (String[] args) {

    boolean isEmpty = false;

    Scanner in = new Scanner (System. in);

    System. out. println ("Is class Rooster Empty? Yes or No");

    String ans = in. next ();

    if (ans. equalsIgnoreCase ("yes")) {

    isEmpty = true;

    }

    else isEmpty = false;

    System. out. println ("Enter number of credits");

    int numOfCredits = in. nextInt ();

    if (isEmpty||numOfCredits==3) {

    System. out. println ("True");

    }

    else {

    System. out. println ("Not true");

    }

    }

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Given two variables, is Empty of type boolean, indicating whether a class roster is empty or not, and number Of Credits of type int, ...” 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