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
Kisachek [45]
3 years ago
13

Write a Java program in jGRASP that creates a 2D integer array of 5 rows and 20 columns, fills it with increasing integer values

ranging from 0 to 59 and then prints the array
Computers and Technology
1 answer:
Alex73 [517]3 years ago
7 0

Answer:

As per the question we need to make 5 rowa and 2o columns, in this we have total element 100 so range should be 0 to 99, but we are suggested to keep range 0 to 59, so i have kept the elementns in the range, but if it was a typo in the question for range you do not need to reset the k with zero.

Explanation:

//create a new class  TestArray

public class TestArray {

//define main method

public static void main(String[] args) {

 //declare a 2D array of given size i.e. 5 rows and 20 columns

 int arr[][] = new int[5][20];

 //declare an integer variable k and initialize it with zero, this will used to initialize the array from 0 to 99

 int k = 0;

 //for loop for rows

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

  //for loop for columns

  for (int j = 0; j < 20; j++) {

   //initialize arr with the current value of k

   arr[i][j] = k;

   //once k is 59 set it zero again as we are not going beyond 59

   if(k == 59)

    k = 0;

   //increment value of k with 1

   k++;

  }

 }

 //print the element from the array one by one

 //for loop for rows

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

  //for loop for columns

  for (int j = 0; j < 20; j++) {

   //print the current element of array and an space with it

   System.out.print(arr[i][j]+" ");

  }

  // move the cursor to new line

  System.out.println();

 }

}

}

You might be interested in
How could TWC continue to leverage mobile apps to further monetize its significant investment in its weather data? What addition
Ann [662]

<u>Explanation</u>:

To effectively Monetise mobile apps the latest trend usually involves focusing on user downloads and active user subscriptions.

Since TWC is a weather data analyst company, providing premium services via it's app not available on TV can increase user signups.

Their app could offer this use cases;

  • A platform were users share live weather data of their location that are factual.
  • Provide paid weather educational courses
8 0
3 years ago
Why is removing presentation-oriented markup from one's html document considered to be a best practice?
Gelneren [198K]

Answer

Its for the purpose of  maintenance and readability

Explanation

A presentation-oriented markup web application generates interactive web pages containing various types of markup language.

Markup is a language designed for the purposes of processing definition and presentation. It specifies code for formatting, both the layout and style, within a text file. Markup describes the structure while the styling is how it looks. it uses the code to specify the formatting which are called tags.

3 0
3 years ago
How to make a water bottle rocket??
k0ka [10]
This question should be in physics so this is my answer in C&T format-go to a online shop and order one or the pieces then follow the instructions that will be given.
6 0
3 years ago
Write a function named replaceSubstring. The function should accept three C-string arguments, let's call them string1, string2,
hoa [83]

Answer:

All is in explanation.

Explanation:

#include <iostream>

#include <cstring>

#include <string>

using namespace std;

//function prototype

string replaceSubstring(const char *, const char *, const char*);

string replaceSubstring(string, string, string);

int main()

{

//declare three char array to hold strings of max 100 chars

char string1[101];

char string2[101];

char string3[101];

//prompt user to enter input

//then read

cout << "Enter string to search:\n";

cin.getline(string1, 101);

cout << "Enter the string you want to replace:\n";

cin.getline(string2, 101);

cout << "What do you want to replace it with?\n";

cin.getline(string3, 101);

cout << "Your updated string is:\n";

cout << replaceSubstring(string1, string2, string3);

//return 0 to mark successful termination

return 0;

}

string replaceSubstring(const char *st1, const char *st2, const char *st3){

//declare pointers start and occurrence

//initialize start with string to search

//char *startSearch = st1;

//initialize occurrence with the first occurrence

//of st2 in st1

char *occurrence = strstr(st1, st2);

//declare empty string

string output = "";

//using occurrence as control for while loop

//means that it will iterate until no more

//occurrences are found

while(occurrence){

//append to final string the characters of st1

//up until first occurrence of st2

output.append(st1, (occurrence-st1));

//append st3 to final string

output.append(st3, strlen(st3));

//update occurrence to point to character

//of st1 just after first occurrence of st2

st1 = st1 + (occurrence-st1) + strlen(st2);

//find new occurrence

occurrence = strstr(st1, st2);

}

//st1 now points to first character after

//last occurrence of st2

output.append(st1, strlen(st1));

return output;

}

string replaceSubstring(string st1, string st2, string st3){

//convert input strings to C-strings

const char *ptr1 = st1.c_str();

const char *ptr2 = st2.c_str();

const char *ptr3 = st3.c_str();

//call function that accepts C-strings

replaceSubstring(ptr1, ptr2, ptr3);

}

6 0
3 years ago
Read 2 more answers
An Operating System is an application just like any other applications we use on our computers. What makes an Operating System s
tatyana61 [14]

Answer: An operating system(OS) is an interface between the hardware and the user. An OS is built so that it could support other software. OS is a system software which is used to support other application softwares.

Explanation:

An operating system handles all the hardware of the system and allows users access to those hardware components with the help of application softwares.

An OS consist of many libraries and APIs which allows programmers to write and execute codes. There are many types of OS such as real time, multitasking, multi programming OS.

The OS is responsible for allocating memory, managing the hardware, distributing resources across different processors in an distributed system.

So all these features makes them different from application software. The OS is responsible allocating memory and hardware resources to these softwares.

3 0
3 years ago
Other questions:
  • The Fully Meets rating should be assigned when the spelling suggestion matches query intent
    11·1 answer
  • The True Confessions of Charlotte Doyle begins with what is called a(n) _____.
    15·1 answer
  • The benefits of flextime include:
    11·2 answers
  • How does Frankenstein feel about his creation?
    15·1 answer
  • Choose two browsers and compare their security features.
    5·1 answer
  • Complete the following conversions. You MUST show all of your work to receive full credit.
    13·1 answer
  • What is the Most popular game out today?
    6·2 answers
  • Name various phases of SDLC in Rational Unified Process (RUP)
    7·1 answer
  • Can someone solve this for me please? It’s part of an escape room.
    13·2 answers
  • Write the icon of full justification​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!