Create a program and inside your program, type the code as given below. Thenrewrite the nested ifs with logical operators.1.int num = 5;// nested ifif ( num > 0 ){if ( num < 10 ){System.out.println( "num is between 0 and 10" ) ;}2.int x = 4;int y = 2;// nested ifif (x >5){if (y > 3){System.out.println ("x is greater and y is greater");else if(x < 5){if (y < 3){System.out.println ("x is less and y is less");elseSystem.out.println ("x is 5 and y is 3");Page 1 of 2CSCI 206 LabDate: 3 March 2020Lab Activity 6: Logical operators & nested ifsType the code as given below, then rewrite the ifs with logical operators withnested ifs.3.int temp = 32;int humidity = 78;// logical operatorsif(temp = 78){System.out.println("It will snow!");else{System.out.println ("What am I? The weatherman?");Output will look like this (the first line being the given code; the repeatedline being the rewritten code):num is between 0 and 10num is between 0 and 10x is less and y is lessx is less and y is lessIt will snow!It will snow!

Question
Asked Mar 3, 2020
18 views
Create a program and inside your program, type the code as given below. Then
rewrite the nested ifs with logical operators.
1.
int num = 5;
// nested if
if ( num > 0 )
{
if ( num < 10 )
{
System.out.println( "num is between 0 and 10" ) ;
}
2.
int x = 4;
int y = 2;
// nested if
if (x >5)
{
if (y > 3)
{
System.out.println ("x is greater and y is greater");
else if(x < 5)
{
if (y < 3)
{
System.out.println ("x is less and y is less");
else
System.out.println ("x is 5 and y is 3");
Page 1 of 2
CSCI 206 Lab
Date: 3 March 2020
Lab Activity 6: Logical operators & nested ifs
Type the code as given below, then rewrite the ifs with logical operators with
nested ifs.
3.
int temp = 32;
int humidity = 78;
// logical operators
if(temp <= 32 && humidity >= 78)
{
System.out.println("It will snow!");
else
{
System.out.println ("What am I? The weatherman?");
Output will look like this (the first line being the given code; the repeated
line being the rewritten code):
num is between 0 and 10
num is between 0 and 10
x is less and y is less
x is less and y is less
It will snow!
It will snow!
help_outline

Image Transcriptionclose

Create a program and inside your program, type the code as given below. Then rewrite the nested ifs with logical operators. 1. int num = 5; // nested if if ( num > 0 ) { if ( num < 10 ) { System.out.println( "num is between 0 and 10" ) ; } 2. int x = 4; int y = 2; // nested if if (x >5) { if (y > 3) { System.out.println ("x is greater and y is greater"); else if(x < 5) { if (y < 3) { System.out.println ("x is less and y is less"); else System.out.println ("x is 5 and y is 3"); Page 1 of 2 CSCI 206 Lab Date: 3 March 2020 Lab Activity 6: Logical operators & nested ifs Type the code as given below, then rewrite the ifs with logical operators with nested ifs. 3. int temp = 32; int humidity = 78; // logical operators if(temp <= 32 && humidity >= 78) { System.out.println("It will snow!"); else { System.out.println ("What am I? The weatherman?"); Output will look like this (the first line being the given code; the repeated line being the rewritten code): num is between 0 and 10 num is between 0 and 10 x is less and y is less x is less and y is less It will snow! It will snow!

fullscreen
check_circle

Expert Answer

Step 1

Hey, since there are multiple questions posted, we will answer first question. If you want any specific question to be answered then please submit that question only or specify the question number in your message.

Step 2

PROGRAM:

//Creating a class with the name of logic

class logic

{

  //Defining the main() function

  public static void main(String[] args)

 {

    /*Declaring the variable n and assigning value to the n variable as 5.*/

          int num=5;

  //using logical operators making the if condition.

          if((num>0)&&(num<10))

          {

    //Printing the statement if the condition becomes true.

           System.out.println("num is between 0 and 10");

          }

}

}

Step 3

SREENSHOT OF THE PROGRAM:

 

Computer Science homework question answer, step 3, image 1

...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Hello, I have an assignment in the python program.  Professor gives me a text like this: January.txt...

A: Python program to generate the January Bank Statement. customer’s account number, beginning balance,...

question_answer

Q: Following the notation seen in class, we have a block cipher that is chained in this way: = Pe XOR E...

A: MAC assist block chaining message authentication (CBC) residue. MAC also assists the continuous XOR ...

question_answer

Q: How to write a program in java that can read numbers from a text file into an array then output thes...

A: The program is divided into 3 parts - part 1 reads the data file, part 2 computes the count of the n...

question_answer

Q: In general, there are two types of grammars for programming languages, regular and context-free, wha...

A: The lexical rules in the case of regular grammar are simple and the notations are quite easy to unde...

question_answer

Q: Having trouble writing this program any help would be appreciated

A: Take a variable to input the age from the user. Take a loop to run until the user wants to exit the ...

question_answer

Q: Assuming nine-bit two’s complement representation, convert each of the following decimal numbers to ...

A: As the question contains multiple sub parts, the answer is provided only for first three sub parts.

question_answer

Q: Error in my Java code! I am not getting the intended results, here are my two classes and output. pu...

A: import java.util.*;class XXX_Course {  private String course_name; public static int count=999; publ...

question_answer

Q: Write the pseudocode for a looping structure that will determine the largest and smallest positive i...

A: Start Initialize the required variables. do { Write "Enter a number:" Get the input from the user if...

question_answer

Q: The question is attached to the image. Please help!

A: Create and initialize the final variable windowWidth and windowheigth. Calculate window area. int wi...