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
Harman [31]
2 years ago
10

Write a piece of code that constructs a jagged two-dimensional array of integers named jagged with five rows and an increasing n

umber of columns in each row, such that the first row has one column, the second row has two, the third has three, and so on. The array elements should have increasing values in top-to-bottom, left-to-right order (also called row-major order). In other words, the array's contents should be the following: 1 2, 3 4, 5, 6 7, 8, 9, 10 11, 12, 13, 14, 15
PROPER OUTPUT: jagged = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15]]
INCORRECT CODE:
int jagged[][] = new int[5][];
for(int i=0; i<5; i++){
jagged[i] = new int[i+1]; // creating number of columns based on current value
for(int j=0, k=i+1; j jagged[i][j] = k;
}
}
System.out.println("Jagged Array elements are: ");
for(int i=0; i for(int j=0; j System.out.print(jagged[i][j]+" ");
}
System.out.println();
}
expected output:jagged = [[1], [2, 3], [4, 5, 6], [7, 8, 9, 10], [11, 12, 13, 14, 15]]
current output:
Jagged Array elements are:
1
2 3
3 4 5
....
Computers and Technology
1 answer:
Ksivusya [100]2 years ago
4 0

Answer:

Explanation:

The following code is written in Java and it uses nested for loops to create the array elements and then the same for loops in order to print out the elements in a pyramid-like format as shown in the question. The output of the code can be seen in the attached image below.

class Brainly {

   public static void main(String[] args) {

       int jagged[][] = new int[5][];

       int element = 1;

       for(int i=0; i<5; i++){

           jagged[i] = new int[i+1]; // creating number of columns based on current value

           for(int x = 0; x < jagged[i].length; x++) {

               jagged[i][x] = element;

               element += 1;

           }

       }

       System.out.println("Jagged Array elements are: ");

       for ( int[] x : jagged) {

           for (int y : x) {

               System.out.print(y + " ");

           }

           System.out.println(' ');

       }

       }

   }

You might be interested in
460N of force is exerted on an object with a surface area of 2,5m.How much pressure is felt by the object?​
BartSMP [9]

Explanation:

p=F/A

p=460N/2m×5m

=46N/m2

7 0
2 years ago
Read 2 more answers
What are the four major software packages of microsoft​
Reika [66]

Answer:

» Microsoft word ( word processing )

» Microsoft powerpoint ( presentation )

» Microsoft access ( database mamagement )

» Microsoft excel ( spread sheets )

Explanation:

.

3 0
2 years ago
Ill give you brainiest.
quester [9]
Hey there,

I believe that your correct answer would be that "<span> some people will tell you what they think you want to hear </span>". When you ask someone about the perceptions of your person trait, they will most likely <span>tell you what they think you want to hear because its what they want to make you happy. 

For example: Jimmy ask billy "Am I fat Billy"

                      Billy tells Jimmy "No, Your not fat, you look just great".

                         But really, Jimmy is very fat.

The point is that people are going to say things that make you feel happy and something that you want to hear.

~Jurgen</span>
6 0
3 years ago
Suppose I have two DFAs D1, D2 and I perform the product construction on them to get a DFA for the union of their languages. Wha
Musya8 [376]

Answer:

Explanation:

If L(D1) = L(D2), the D has every state being final

If L(D1) = L¯(D2), the D has every state being final

If L(D1) = ∅, then L(D) = L(D2).

If L(D1)=Σ, L(D) = L(D2)

8 0
2 years ago
Reed Hastings created Netflix. His inspiration came from the fact that he had to pay a sizeable late fee for returning a DVD bey
noname [10]

Answer:

Which statement accurately describes his key to success?

Explanation:

The success in Netflix lies in offering:

1. Entertainment;

2. fun;

3. originality;

4. innovation and

5. happiness.

Netflix learning is:

1. Bet on your content.

2. Brand Personality.

3. Visual universe.

4. Customization

5. Big Data helps Netflix continue to grow and improve customer service.

3 0
2 years ago
Other questions:
  • What is an examlple of cyberbullying
    5·1 answer
  • An ethernet switch has a ____ table which is updated by ______.
    14·1 answer
  • Which statement is used to create a file object that will append data to an existing file? BufferedWriter salesdata =
    7·2 answers
  • So can u please follow my new ig acc i just started it yesterday its called stunnerspamz
    5·2 answers
  • In what form do the hexadecimal numbers need to be converted for a computer’s digital circuit to process them?
    10·1 answer
  • Courses that enable students to begin jobs that require course completion certificates are know as
    8·1 answer
  • ​Client/server computing is​ a: A. network that connects sensors to desktop computers. B. distributed computing model where clie
    12·1 answer
  • Which company provides a crowdsourcing platform for corporate research and development?
    9·1 answer
  • Refer to the image on the right. Then, using the drop-down menu, identify the correct printer type. A: inexpensive home printer
    10·1 answer
  • What do we call notes in computer code for the programmer that are ignored by the compiler?.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!