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
solmaris [256]
4 years ago
12

Create a static method called fillArray, which takes an integer array as an input parameter, along with an integer initial value

. It should then fill the array with values starting from the initial value, and counting up by 1s. For example, if the data array has length 5, and if the initialValue is 3, then after execution the array should hold this sequence: 3 4 5 6 7. public static void fillArray (int[] data, int initialValue) {
Computers and Technology
1 answer:
JulijaS [17]4 years ago
3 0

Answer:

public class print{

   

   public static void fillArray(int[] arr, int initialValue){

       

       int n = arr.length;

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

          arr[i] = initialValue++;

      }

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

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

      }

       

   }

    public static void main(String []args){

       

        int[] array = new int[5];

        int initialValue =3;

       

        fillArray(array,initialValue);

       

    }

}

Explanation:

Create the function with two parameter first is array and second is integer.

Then, declare the variable and store the size of array.

Take the for and fill the array from the incremented value of initialValue  by 1 at every run of loop.

After loop, print the element of the array.

Create the main function which is used for calling the function and also declare the array with size 5 and initialValue with 3. After that, call the function with this argument.

You might be interested in
Write a function named repeat_words that takes two string parameters: 1. in_file: the name of an input file that exists before r
madam [21]

Answer:

#section 1

def repeat_words(firstFile, secondFile):

   infile_1=open(firstFile,'r')

   content1=infile_1.read()

   infile_1.close()

#section 2

   import string

   newContent=""

   for char in content1:

       newContent+=char.strip(string.punctuation)

   newContent=newContent.lower()

   newContent=newContent.split()

#section 3

   repeated_list=[]

   for word in newContent:

       if newContent.count(word)>1:

           repeated_list.append(word)

#section 4

   new_repeat_list=[]

   for item in repeated_list:

      while item not in new_repeat_list:

         new_repeat_list.append(item)

#section 5

   outfile=open(secondFile,'w')

   for repeat in new_repeat_list:

       outfile.write(repeat)

       outfile.write('\n')

   outfile.close()

   infile_2=open(secondFile,'r')

   content2=secondFile.read()

   infile_2.close()

   return content2

# section 6

in_file = 'aa.txt'

out_file = 'cpu.txt'

print(repeat_words(in_file, out_file))

Explanation:

#section 1

it defines a function that takes two arguments. It opens the first argument in the read mode and stores all it's content in a string variable "content1". finally the file is closed.

#section 2

In this section the string module is imported which allows for easy manipulation of string variables.

A new string variable is created that would store the already stripped file.

<em>strip(string.punctuation)  </em>strips every character of any leading or trialing punctuation.

<em>lower()  </em>converts string to lover case.

<em>split() </em>converts a string to an array of sub-string, i.e an array of words.

#section 3

This section collects all the words in the array and places them in a list.

#section 4

Utilizes a For and a While loop to ensure that no word repeats and stores it in a new list.

#section 5

Opens a new file and writes all the content into that new file and then closes the file.

re-opens the file, reads and returns the content of the file.

# section 6

This is added in order to test the function and print the result

I used your question to test the function and attached the result.

cheers!

8 0
3 years ago
HELP PLEASE I WILL GIVE YOU 15 POINTS!
scoundrel [369]

Answer:

look up some stories if you can like about dogs or something and then write why you like animals then write about how much you need to know about dogs or cats to be a good dog/cat owner

Explanation:

I already gave you the two stories didn't I in your last questions?

4 0
3 years ago
design an if-then-else statement or a flowchart with a dual alternative decision structure that displays speed is normal if the
Monica [59]

Answer:

The if statement is as follows:

if speed>=24 and speed <=56 then

      print "speed is normal"

else

    print "speed is abnormal"

<em>See attachment for flowchart</em>

Explanation:

The condition is straight forward and self-explanatory

This is executed if speed is between 24-56 (inclusive)

<em>if speed>=24 and speed <=56 then</em>

<em>       print "speed is normal"</em>

If otherwise, this is executed

<em>else</em>

<em>     print "speed is abnormal"</em>

<em />

4 0
3 years ago
Which two characters do you use to tell the command that you are finished providing options and that the remaining data on the c
sergiy2304 [10]

Answer:

Two hyphen-minus characters (- -)

Explanation:

Using two hyphen-minus characters only, tend to recommend that the rest of the data are arguments and should not be treated as alternatives.

Hence, in this situation, the two characters a user will use to tell the command that a user is complete giving options and that the rest of the data on the command line is arguments is known as "two hyphen-minus characters (- -)"

8 0
4 years ago
Software is written by software developers using computer-readable code called a(n) _______. A set of instructions that tells a
alekssr [168]

Answer:

Following are the answers according to their occurrence.:-

  1. programming language.
  2. software.
  3. update.
  4. custom.
  5. system.

Explanation:

Software developers write their codes in the programming languages such as  JAVA,C++,C,Python etc.

A software is a set of instructions developed by an software developer tells a computer what to do.

Software update is an up gradation of a software where the old programming codes are replaced by new codes.

Custom installation lets you install the software at your desired location and you can install selected features instead of all the features.

System software lets you use the computer when the first time you start the computer.

6 0
4 years ago
Other questions:
  • Write a program that defines a type for a structure that stores information on a student in ENG EK 125. Declare two variables to
    8·1 answer
  • What is the name given to the software testing technique, which basically consists of finding implementation bugs using malforme
    7·2 answers
  • Clicking on the Spelling &amp; Grammar button is one way to correct a spelling error in Word. Please select the best answer from
    7·2 answers
  • Clunker Motors Inc. is recalling all vehicles from model years 2001-2006. Given a variable modelYear write a statement that prin
    8·1 answer
  • How do computers use input and output to get and give the information that they need to solve problems?
    10·1 answer
  • While performing Before Operations PMCS, you notice the front right tire appears slightly underinflated. What is the proper acti
    11·1 answer
  • What is thhe name of service included with windows server operating systemthat manages a centralized database containing user ac
    5·1 answer
  • Using media allows us to:
    15·1 answer
  • Pick the correct statements on the 64-bit machine representation of numbers.
    5·1 answer
  • A combined counting and logical looping statement may be needed in the following situations: (a). The values stored in a linked
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!