2. Boolean Operations&&


#1



https://www.codecademy.com/en/courses/learn-java/lessons/conditionals-control-flow/exercises/boolean-operators-and?action=lesson_resume&link_content_target=interstitial_lesson

I really don't understand what they are telling me to do. Can someone help? Thanks

public class Conditionals {
	public static void main(String[] args) {


		if (1 < 4 && 0 > 5) {

			System.out.println("You ordered a cup of hot, mint tea.");

		} else if (21 <= 19 || 17 >= 28) {
			
			System.out.println("You ordered freshly squeezed orange juice!");

		} else if ( !(true == true) ) {

			System.out.println("You ordered hot cocoa!");

		} else {

			System.out.println("You ordered a cup of Java!");

		}

		char answerChoice = 'C';

		switch (answerChoice) {

			case 'A': System.out.println("You answered: " + answerChoice + ". Please try again.");
								break; 

			case 'B': System.out.println("You answered: " + answerChoice + ". Please try again.");
								break;

			case 'C': System.out.println("You answered: " + answerChoice + ". That is correct!");
								break;

			case 'D': System.out.println("You answered: " + answerChoice + ". Please try again.");
								break;

			default:
				System.out.println("Please select a valid answer choice.");

		}


	}
}


#2

What are you supposed to do? What is confusing you regarding the code you have provided?


#3

@blackestpanther,
Could you provide us with the Instructions,
as i am not able to access this conditional course-part

What you should understand::

JAVA uses the strict class concept...
They have build their course, using class-modules
like this module

public class Conditionals {
      //Here you define code
}

Within this publicly-accessable Conditional class
they insert a main() function
by using

public static void main(String[] args) {
     //your course-code
}

Now if you =click= the Run button
it is this publicly-accessable main() function
which will be executed by the course-software.
And as the main() function is defined as static void it will NOT give a return Value.

Thus we have

public class Conditionals {
	public static void main(String[] args) {
               // =main()= function code-block
               // also called the FUNCTION-BODY

               // it is here where we are going to 
               // = define an IF ELSE IF statement
               // = define a switch statement

        }
}

==========================================

From
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html
you should familiarize yourself with
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html
and
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/if.html
and
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/switch.html


#4

Why does the code

if ( !(true == true) ) {

		System.out.println("You ordered hot cocoa!");

return a false?


#5

Do the ( ) first:

(true == true)  // evaluates to true
!true  // evaluates to false