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
The difference between a want and a need is a want is not necessary for survival. Things necessary for survival are known as ___
Zarrin [17]
A.Needs since they are necessary and needed for survival 
8 0
4 years ago
3.What is the difference between SODIMM and UniDIMM?
lorasvet [3.4K]

Answer:

Small Outline Dual Inline Memory Module and Unbuffered Dual Inline Memory Module are two terms that describe types of computer memory. While UDIMM is a generic term that applies to most memory modules, SO-DIMM modules are used almost exclusively in notebook computers

Explanation:

6 0
4 years ago
In a database, data is stored in spreadsheets which have rows and columns.
Tcecarenko [31]
The answer is A. True.
5 0
3 years ago
Each high-level language has its own __________, or rules of the language. group of answer choices
il63 [147K]

Each high-level language has its own syntax which is also called rules of the programming language. Therefore, the correct choice is syntax.

High-level languages have a greater level of abstraction from details of the computer. They focus more on the programming logic which is closely associated with human understanding instead of the underlying hardware modules. Each high-level programming language has its own specific set of rules which is known as the syntax of that language.

Syntax of the high-level languages define structure and formation of the statements in the language. In order to write a program in any high-level programming language, proper syntax of that programming language requires to be followed.

If the syntax of the programming language is not followed properly, the compiler will produce errors. In result, required output of the program will not be generated because of the failure of the program execution.

You can learn more about syntax at

brainly.com/question/831003

#SPJ4

5 0
2 years ago
Write a recipe that stores the sum of the numbers 12 and 33 in a variable named sum. Have your recipe display the value stored i
VARVARA [1.3K]

Answer:

#include<iostream>

using namespace std;

int main(){

   int sum = 12+33;

   cout<<"The sum is: "<<sum<<endl;

}

Explanation:

First include the library iostream in c++ program for input/output.

Then, create the main function and declare the variable sum as integer type and store the sum of two given values.

After that, display the result store in the sum variable on the screen by using the instruction cout.

8 0
3 years ago
Other questions:
  • Combination keys perform a function when held down in combination with another key. true or false
    9·1 answer
  • What is the role of the ieee in computer networking and wireless communications?
    14·1 answer
  • Write a program named SortWords that includes a method named SortAndDisplayWords that accepts any number of words, sorts them in
    10·1 answer
  • 1. Why is it important for IT technicians to keep documentation on computers for which they are
    13·1 answer
  • Someone help meeeeeeeee plz.......................
    11·2 answers
  • Write down the different types of testing with their definition.
    11·1 answer
  • Which component of the computer keeps the operating system when the computer is running​
    10·1 answer
  • Watch any film of the silent era. Choose a short film from any genre that is less than 30 minutes long. Write a review of your e
    12·1 answer
  • which type of virtual machine (vm) takes advantage of unused capacity in data centers at a much lower cost than regular vms of s
    5·1 answer
  • Add this in binary numbers . (1100011+11111+111) ​
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!