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
PLEASE HELP!
Alex73 [517]
The Filter function will allow her to quickly find this data. It is not impossible using the Sort function, but it will take much longer and involve a lot of manual cutting, pasting or deleting of unnecessary data.


D.)Laura can apply a Filter for the top 10 students and a Filter for which schools to exclude from the results.
5 0
3 years ago
Read 2 more answers
A(n) __________attack is designed to render the target unreachable by legitimate users, not to provide the attacker access to th
Nimfa-mama [501]
Denial of Service or Distributed Denial of Service.
3 0
3 years ago
Which of the following scenarios falls into the category of network crimes?
solong [7]

Answer:

B

Explanation:

Hope it helps!

3 0
2 years ago
Read 2 more answers
Describe the user interface in other high-technology devices commonly found in the home or office, such as a smartphone, HD tele
Vadim26 [7]

Answer:

Explanation:

Different technologies use different user interface designs in order to make the user experience as easy and intuitive as possible. This varies drastically from one device to another because of the capabilities and size of each device. If we take a fitness/smart watch into consideration, this device does not use pop up menus or side scrolling menus but instead uses large full screen menus where each option nearly fills the entire screen. That is done because the smart watch screens are very small and making everything full screen makes reading and swiping through options that much easier for the user. If the user interface were the same as in a television or smartphone it would be impossible to navigate through the different options on such a tiny screen.

7 0
3 years ago
In Microsoft word,when you highlight existing text you want to replace ,you’re in?
Lerok [7]

In Microsoft Word, when you highlight existing text you want to replace, you are in overtype or typeover mode. However, this may also be the case when you are in the Find and Replace tool, where you will type in all the exact phrases or words that will eventually be highlighted and then be replaced in just one click.

5 0
3 years ago
Other questions:
  • Which key on a laptop keyboard is often used to help pair a mobile device with another device for communication purposes?
    12·1 answer
  • A network administrator is required to upgrade wireless access to end users in a building. To provide data rates up to 1.3 Gb/s
    12·1 answer
  • Angle, oblique, regular, demi, roman, heavy, extra bold, expanded, and compressed are ___________ . Select one: A. type styles B
    10·1 answer
  • Science is a body of knowledge that extends back to Select one: a. the time of Galileo. b. Italy in the 16th century. c. Greece
    6·1 answer
  • This is a text message that is stored on a user's computer by a Web server that helps trace the user's browsing habits. a. Scrip
    14·1 answer
  • What can help an interface user understand or navigate an online interface?​
    15·1 answer
  • 1
    7·1 answer
  • Write a java program to create and display unique three digit number using 1,2,3 and 4 also count how many three digit number ar
    10·1 answer
  • Write, in your own words, a one-two paragraph summary on the Running Queries and Reports tutorials. Apply critical thinking and
    10·1 answer
  • I am booooooored any one want to join
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!