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
How do you put a voice password on your computer using windows 10
valkas [14]
I think you need some time of camra voice recorder sorry if im wrong also sorry cuz i forgot what it is called
7 0
2 years ago
Write the Flowchart to find Even number between 1 to 50<br>​
ASHA 777 [7]

Answer:

See attachment for flowchart

Explanation:

Required

Flowchart to fine even from 1 to 50

The flowchart has been attached.

The rough algorithm (explanation) of the flowchart is as follows.

1. Start

2. Initialize num to 1

3. Check if num is less than or equal to 50

  3.1 If yes

      3.1.1 Check if num is even

      3.1.1.1 If yes

         3.1.1.2 Print num

  3.1.3 Increase num by 1

 3.2 If num is greater than 50

    3.2.1 Stop

4. Goto 3

4 0
3 years ago
What will be the value of x after the following loop terminates?
Katena32 [7]

Answer:

10

Explanation:

This for-loop is simply iterating three times in which the value of x is being set to the value of x * 1.  So let's perform these iterations:

x = 10

When i = 0

x = x * 1 ==> 10

When i = 1

x = x * 1 ==> 10

When i = 2

x = x * 1 ==> 10

And then the for-loop terminates, leaving the value of x as 10.

Hence, the value of x is equal to 10.

Cheers.

7 0
2 years ago
Match the academic requirements with the careers. Technical program , bachelors degree, doctorate degree can go with cosmetologi
Evgesh-ka [11]
Technical program - cosmetologist
Bachelors degree - nutritionist
Doctorate degree - molecular biologist
All careers are dependent on the required education for a particular career and the complexity of education to be competent.
8 0
3 years ago
Read 2 more answers
What is the first thing you should do to find a mean and range of data?
KatRina [158]

Answer

To find mean of data add all the numbers in the set of data and divide the sum by the number of addends.

To find range, identify the difference between the highest value and lowest value in the set of data.

Explanation

Mean, mode, median and range are the primary measurements used to get the measures of central tendencies. To get the mean and range; first arrange the data in an ascending order, then identify the highest value and the lowest value in the set. The difference between these two data values gives the range of the set of values. For the mean, add all the set of values and then divide their sum with the number of values in the set of data.


6 0
3 years ago
Other questions:
  • What are five features of word 2016 you would use to capture the attention of the target audience? Defend you decisions
    9·1 answer
  • A _____ is a device that not only provides surge protection, but also furnishes desktop computers and network devices with batte
    7·1 answer
  • Mr. Perry has bookmarked a large number of webpages in Chrome while researching class topics. Unfortunately, he's bookmarked so
    13·1 answer
  • Universal Containers is tracking the interviewer's ratings of candidate in Salesforce. They would like to easily link the Candid
    5·1 answer
  • WHAT IS A COMPUTER ????
    14·2 answers
  • When performing a basic search with Bing, you first type in your search expression and then click a button to begin the search;
    13·1 answer
  • Write a program that:
    13·1 answer
  • Which are examples of types of audio media that can support a presentation? Check all that apply.
    14·2 answers
  • Using complete sentences post a detailed response to the following.
    13·1 answer
  • NEED ANS ASAP THANK YOU
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!