1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Serjik [45]
3 years ago
7

Iven the code fragment below with nested if statements, rewrite the code to combine all the tests into one if statement with mul

tiple conditionals. Paste (or type) the rewritten code into your answers document.
int feb = 28;

if ((year % 4) == 0) // assume that year is an integer with a valid year value

{

if ((year % 100) != 0)

{

System.out.println("This is a leap year");

feb = 29;

}

}

If the value of year is 2020, what will the value of feb be after this code runs?
Computers and Technology
2 answers:
Georgia [21]3 years ago
8 0

Answer:

See Explanation Below

Explanation:

The new code segment is

int feb = 28;

if ((year % 4) == 0 && (year % 100) != 0) // assume that year is an integer with a valid year value

{

System.out.println("This is a leap year");

feb = 29;

}

Assume year = 2020, the assigned value of feb is 29;

Reason below;

At line 2 of the new code segment, two conditions are tested both of which must be satisfied.

1. year % 4 == 0

2020 % 4 = 0

0 = 0 (True)

2. year % 100 != 0

2020 % 100 != 0

20 != 0 (True)

Since both conditions are true, the value assigned to feb will be 29 and

"This is a leap year" will be printed without the quotes

trasher [3.6K]3 years ago
6 0

Answer:

public class Main {

   public static void main (String [] args) {

       int year = 2016;

       int feb = 28;

       if ((year % 4) == 0 && (year % 100) != 0)

       {

               System.out.println("This is a leap year");

               feb = 29;

       }

   }

}

Explanation:

We can use the and logical operator, &&, to join the nested if statements into one single statement. The and operator will first evaluate the condition year % 4 is equal to zero and then followed with checking if year % 100 is not equal to 100. If only both conditions are met, it will evaluated to true and then go in to the if block to print the message "This is a leap year" and set 29 to variable feb.

You might be interested in
Why is experience in their own factory setting
Nataly [62]

Answer:

How to Manage Manufacturing Operations Effectively

Ensure High-Quality Products. ...

Ensure High-Quality Equipment. ...

Know How To Maximize Resources. ...

Look Into Technological Advancements. ...

Check Your Customer Service. ...

Consider Reducing Waste. ...

Conclusion.

Explanation:

5 0
2 years ago
Types of Computer games​
kiruha [24]

\bold{Hello}~

\bold{Answer:}

<h3>Types of Computer games</h3>
  • Action
  • Adventure
  • Simulation
  • Sports
  • Role-playing
  • Puzzlers
  • Party games

<em>(</em><em>That's</em><em> </em><em>all</em><em> </em><em>i</em><em> </em><em>know</em><em>)</em><em> </em>

<h2>#Hopeithelps\:</h2>

\bold{-Kei}~

\tiny\sf\purple{ ♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡ }

5 0
2 years ago
Which of the following best reflects why lighting systems are used when filming on location outdoors? (Select all that apply.)
cupoosta [38]
<h2>All the given answers are right</h2>

Explanation:

  • Lighting is one of the key factor which is essential to do cinematography
  • It will help to cut off the shadows that is created using natural light
  • It can depict the mood of the scene that is shoot
  • We can adjust manually brightness and darkness according to the need, which is not possible in the natural light.
  • It can boost the quality of the footage
  • We can shoot anytime irrespective of the weather condition
  • The light from the camera alone is not enough to shoot the best picture
8 0
3 years ago
Write a function named shareALetter that takes one parameter, wordList – a list of words. Create and return a dictionary in whic
Arte-miy333 [17]
Can u send anything to understand it
7 0
3 years ago
Which of the following best explains the different between Cut and Copy? a. When you copy text you are permanently deleting it,
Vilka [71]
B. When you copy text it remains in its original location and places it on the clipboard. Cutting text removes it from its original location and places it on the clipboard

5 0
3 years ago
Read 2 more answers
Other questions:
  • Company A is setting up a network of mostly Windows machines. Which networking file system protocol would you recommend for maxi
    5·1 answer
  • In your presentation you added a text box to?
    5·1 answer
  • Which of the following is not considered as part of technology literacy?
    8·1 answer
  • Using information from the lesson, explain how new technologies change your experience as a consumer.
    5·2 answers
  • What is the best way to locate where my C program gets into an infinite loop
    5·1 answer
  • Computers help eliminate that repetitive of manual task. How can this benefit you in in your overall career
    7·2 answers
  • Cryptography has requirements include:
    8·1 answer
  • A business needs to open at the right ___________ and the right ______________. Choose all correct answers.
    9·1 answer
  • A classic game, Wario Land, has an invincible main character who reacts to the environment in order to solve puzzles. So, for ex
    11·1 answer
  • The layer of the ISO/OSI responsible for source to destination delivery.
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!