230k views
2 votes
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.

User Wnajar
by
5.1k points

1 Answer

4 votes

Answer:

if(isEmpty || numOfCredits==3){

}

Step-by-step 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");

}

}

}

User Mrded
by
4.3k points