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
A password checking system that disallows user passwords that are proper names or words that are normally included in a dictiona
nikdorinn [45]
The answer is control
7 0
3 years ago
An airline company would like to easily locate lost luggage. What technology would make it easier for them to locate the luggage
viktelen [127]

R.F.ID Radio  frequency identification  

3 0
3 years ago
Read 2 more answers
What type of attacks take advantage of vulnerabilities in poorly coded web application software to introduce malicious program c
Yakvenalex [24]

Answer:

SQL Injection

Explanation:

Coding a web application that uses a database is requiring close attention, where the developer closes any loophole any attacker may later want to exploit when the application is deployed. SQL Injection is a type of attack where the attacker places malicious code in the query statements through the form. This is possible if the input is not properly sanitized and cleaned.

5 0
3 years ago
Which phrase suggests feedback?
butalik [34]

Answer:

They also gave suggestions on some modules and said they would like to work with his team in the future.

Explanation:

This statement suggests feedback because, here the client gives Richard and his team some suggestions on what they can do with the modules. It implies that the client must have tested the software application and observed its functionality.

7 0
2 years ago
From your computer you are able to establish a telnet connection to a remote host but a traceroute to the host IP address result
Tanya [424]

Mostly firewalls may protect trace route to the host IP address.

<u>Explanation:</u>

When telnet has established the connection to a remote host. Then kindly check the host IP address and their gateway settings.  

If any resident firewall such as antivirus is stopping the ping method or gate way firewall is protecting both ends during trace route. Once the connection is established don’t worry about trace route on host IP  address.

Kindly check where the disconnections happens during the trace route.  in case it happens in between then they're stability on the connection issue which should be solved immediately.

8 0
3 years ago
Other questions:
  • SELECT vendor_name, COUNT(*) AS number_of_invoices, MAX(invoice_total - payment_total - credit_total) AS balance_due FROM vendor
    15·1 answer
  • .exe, .msi, .msp, .inf - together, what do these filetypes indicate
    12·2 answers
  • Which type of denial of service attack exploits the existence of software flaws to disrupt a service?
    12·1 answer
  • How can parents be health educators in family​
    13·1 answer
  • I need le help, darn ijourneys
    10·2 answers
  • Of the following online activities, identify the TWO that are most likely to be affected by bandwidth quality
    11·1 answer
  • What factors do network consultants consider when determining the network needs of a business? Use the space provided below to a
    6·1 answer
  • Any my hero academia fans out there don't report at all just what more friends to
    14·2 answers
  • One rule in the Java programming language is that you have to place a semicolon at the end of each statement. What is this rule
    10·2 answers
  • 4. In computers, an integer can be represented by more than 8-bit, what is the largest positive integer that
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!