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
Maslowich
3 years ago
6

Consider the following code segment. int[][] arr = {{3, 2, 1}, {4, 3, 5}}; for (int row = 0; row < arr.length; row++) { for (

int col = 0; col < arr[row].length; col++) { if (col > 0) { if (arr[row][col] >= arr[row][col - 1]) { System.out.println("Condition one"); } } if (arr[row][col] % 2 == 0) { System.out.println("Condition two"); } } } As a result of executing the code segment, how many times are "Condition one" and "Condition two" printed?
Computers and Technology
1 answer:
ludmilkaskok [199]3 years ago
3 0

Answer:

Condition one - 1 time

Condition two - 2 times

Explanation:

Given

The above code segment

Required

Determine the number of times each print statement is executed

For condition one:

The if condition required to print the statement is:  <em>if (arr[row][col] >= arr[row][col - 1]) </em>

<em />

For the given data array, this condition is true only once, when

row = 1  and  col = 2

i.e.

<em>if(arr[row][col] >= arr[row][col - 1]) </em>

=> <em>arr[1][2] >= arr[1][2 - 1]</em>

=> <em>arr[1][2] >= arr[1][1]</em>

<em>=> 5 >= 3 ---- True</em>

<em />

The statement is false for other elements of the array

Hence, Condition one is printed once

<em />

<em />

For condition two:

The if condition required to print the statement is:  <em>if (arr[row][col] % 2 == 0) </em>

<em />

The condition checks if the array element is divisible by 2.

For the given data array, this condition is true only two times, when

row = 0  and  col = 1

row = 1  and  col = 0

i.e.

<em>if (arr[row][col] % 2 == 0) </em>

<em>When </em>row = 0  and  col = 1

<em>=>arr[0][1] % 2 == 0</em>

<em>=>2 % 2 == 0 --- True</em>

<em />

<em>When </em>row = 1  and  col = 0

<em>=>arr[1][0] % 2 == 0</em>

<em>=> 4 % 2 == 0 --- True</em>

<em />

<em />

The statement is false for other elements of the array

Hence, Condition two is printed twice

You might be interested in
Ultraportable computers will often use ___ technology exclusively, even though their storage capacity is lower than that of a tr
ki77a [65]

Answer:

SSD

Explanation:

8 0
2 years ago
Write an ALTER TABLE statement that adds two new columns to the Products table: one column for product price that provides for t
matrenka [14]

Answer:

ALTER TABLE Products

ADD Products_price float(5,2) DEFAULT 9.99,

ADD Adding_time datetime;

Explanation:

So at first we need to use ALTER TABLE statement, when we use this statement we also need to provide the table name. In this case, i assume it is 'Products'.

Then, as per question, we need to add two columns.

The first one is 'product_price' and it contains decimal points. So, we need to use ADD statement and give a column name like 'Prodcuts_price' and its datatype 'float' because it contains decimal or floating points. so, for 3 digits on the left and 2 digits on the right, it makes a total of 5 digits. So, we need to declare it like this. (5,2) it means a total of 5 digits and 2 after the decimal point. after that, we need to set our Default value using the DEFALUT statement. so DEFAULT 9.99. it will set the default value to 9.99 for existing products.

And for our next column, we give its a name like 'Adding_time' then it's datatype 'datetime' because it will contain date and times.

8 0
3 years ago
Identify at least three tips you would give to people to stay safe on the Internet so that their information stays secure. Expla
Soloha48 [4]

Answer:

1. Do not give away personal information such as your address, school you go to, or anything like that (obvious reasons

2. Do not share your passwords because people can hack into your things

3. Don't make guessable passwords such as Cookies, ILovePizza, Money

7 0
3 years ago
Read 2 more answers
Ramesh goes to market for buying some fruits and vegetables .He
3241004551 [841]

Answer:

The algorithm is as follows

1. Start

2. Input Apple unit price

3. Input Mango unit price

4. input Tomato unit price

5. Total = Apple Price * 2 + Mango Price * 2 + Tomato Price

6. Display Total

7. End

Explanation:

Start the algorithm

1. Start

The next three lines gets input for the price of each fruit

<em>2. Input Apple unit price</em>

<em>3. Input Mango unit price</em>

<em>4. input Tomato unit price</em>

This calculates the total price

5. Total = Apple Price * 2 + Mango Price * 2 + Tomato Price

This displays the total price

6. Display Total

Stop the algorithm

7. End

5 0
3 years ago
Terri brought a magazine for $5, and 2 bottles of nail polish. Write an expression to represent the total amount she spent. Then
kykrilka [37]

The expression that can be used to represent the total amount Terri spent is C = 5 + 2x

<h3>How to write equation</h3>

  • Cost of magazine = $5
  • Number of nail polish bought = 2 bottles

let

x = cost of each nail polish

Total cost, C = magazine + nail polish

C = 5 + 2x

  • If cost of each nail polish = $3

C = 5 + 2x

= 5 + 2(3)

= 5 + 6

C = $11

Learn more about equation:

brainly.com/question/16863577

3 0
2 years ago
Other questions:
  • Consists of a drive letter (preceded by a drive name when necessary) and colon, to identify the storage device, and one or more
    5·1 answer
  • One of the most toxic components of a computer is the
    11·1 answer
  • What does it mean to say that two variables are negatively correlated?
    6·1 answer
  • Using the notation exemplified in following question , list a set of tables and attributes (and identify keys) to represent the
    10·1 answer
  • public interface Displayable { void display(); } public class Picture implements Displayable { private int size; public void inc
    14·1 answer
  • What process periodically validates a user’s account, access control, and membership role on inclusion in a specific group?a. Re
    12·1 answer
  • Before creating a brief to design a product, what is needed
    8·1 answer
  • What is the best motivation that you can do/give to make your employees stay? ​
    6·1 answer
  • 6
    9·1 answer
  • Write a Java program that will be able to generate the sample table below.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!