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
Draw the following diagrams to represent the information system chosen in assignment 1 Context diagram The context diagram is ex
larisa86 [58]

An example of Context diagram that shows the Relevant system name and External Entities Input and output data flows is given in the image attached.

<h3>What is context diagram?</h3>

Context diagrams is known to be a depiction that is based on how external entities work together with a given system.

Note that it is said to be one of the most basic form of a data flow as it depicts a novel set of activities and also functions.

Therefore, An example of Context diagram that shows the Relevant system name and External Entities Input and output data flows is given in the image attached.

Learn more about  Context diagram from

brainly.com/question/12972996

#SPJ6

8 0
2 years ago
Read 2 more answers
Which style of leadership would be most effective in the following situation?
gtnhenbr [62]
Delegate tasks to each person equally by finding out who wants to do what task. Vote on a list of books, come up with a list of possible projects and vote on it again. Figure out the specifics for the project and delegate work equally. Compromise also works if there's a particular part no one wants to do, that way you can all share the workload.
8 0
3 years ago
1.The most common way by which data is input into the computer is through the______________.A.Mouse
xxMikexx [17]

Answer:

b

Explanation:

3 0
3 years ago
Read 2 more answers
To create a new table by using a select statement, you code the ___________________________ clause.
Veronika [31]
Ctrl+t................. .................. .................... ........................
6 0
3 years ago
So, I need to use an external mic for my phone, but the problem is that I need a "dual mic adapter". My dad gave me an "audio sp
hoa [83]

But you can't use this device alone to connect two microphones to your USB C port and expect it to have usable volume. So the description is somewhat misleading ...

5 0
2 years ago
Other questions:
  • Linotype is similar to letterpress since both utilize lead type. The difference is that in a linotype, the type is cast into ful
    11·1 answer
  • “Green Technology” is also known as what?
    11·1 answer
  • Which of the following is NOT a destination?
    12·2 answers
  • Assume that name has been declared suitably for storing names (like "Amy", "Fritz" and "Moustafa"). Assume also that stdin is a
    15·1 answer
  • To mitigate the effects of most of the common network threats including disruption, destruction and disaster, companies are begi
    11·1 answer
  • Which of the following describes creative work that can be used without permission because it is owned by the public and not an
    6·1 answer
  • When Judy logged on the network, she faced the message requesting that she changes her password. So, she changed her password. B
    10·1 answer
  • What statement describes the last step in evaluating<br> information?
    10·1 answer
  • (40 PTS) Be specific
    12·1 answer
  • ________ is a utility program included with most operating systems that allows you to move or eliminate files and give your oper
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!