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
ivanzaharov [21]
3 years ago
8

Create a method called nicknames that passes an array as a parameter. Inside the method initialize it to hold 5 names of your ch

oice. Use the for each enhanced loop to print the elements of the array.
Computers and Technology
1 answer:
Gre4nikov [31]3 years ago
6 0
<h2>Answer:</h2>

    //======METHOD DECLARATION=========//          

    //method name: nicknames                                          

    //method return type: void                                            

    //method parameter: an array reference                    

    public static void nicknames(String [] names){      

       //initialize the array with 5 random names              

       names = new String[] {"John", "Doe", "Brian", "Loveth", "Chris"};

       //using an enhanced for loop, print out the elements in the array

       for(String n: names){

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

       }

       

    }

<h2>Explanation:</h2>

The program is written in Java. It contains comments explaining important parts of the code. Kindly go through these comments.

A few things to note.

i. Since the method does not return any value, its return type is <em>void</em>

ii. The method is made public so that it can be accessible anywhere in and out of the class the uses it.

iii. The method is made static since it will most probably be called in the static main method (at least for testing in this case)

iv. The method receives an array of type <em>String </em>as parameter since the names to be stored are of type <em>String</em>.

v. The format of initializing an array manually should follow as shown on line 7. The <em>new</em> keyword followed by the array type (String), followed by the square brackets ([]) are all important.

vi. An enhanced for loop (lines 9 - 11) is a shorthand way of writing a for loop. The format is as follows;

=> The keyword <em>for</em>

=> followed by an opening parenthesis

=> followed by the type of each of the elements in the array. Type String in this case.

=> followed by a variable name. This holds an element per cycle of the loop.

=> followed by a column

=> followed by the array

=> followed by the closing parenthesis.

=> followed by a pair of curly parentheses serving as a block containing the  code to be executed in every cycle of the loop. In this case, the array elements, each held in turn by variable n, will be printed followed by a space.

A complete code and sample output for testing purposes are shown as follows:

==================================================

public class Tester{

    //The main method

    public static void main(String []args){

       

       String [] names = new String[5];

       nicknames(names);

    }

   

  //The nicknames method

    public static void nicknames(String [] names){

       names = new String[] {"John", "Doe", "Brian", "Loveth", "Chris"};

       for(String n: names){

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

       }

       

    }

}

==================================================

<h2>Output:</h2>

John Doe Brian Loveth Chris

<em>NB: To run this program, copy the complete code, paste in an IDE or editor and save as Tester.java</em>

You might be interested in
How do I do a PowerPoint
kirill115 [55]
It is like this: . You just put a circle and that is a power point
4 0
3 years ago
Read 2 more answers
A network is a group of two or more computers or devices connected together. To be able to connect, they each need a
Kay [80]
D. Internet service protocol (isp)
6 0
3 years ago
Read 2 more answers
A major retailer wants to enhance their customer experience and reduce losses
Mrac [35]

Answer:

Predict Demand

Explanation:

The type of Artificial Intelligence (Al) solution that would be suitable for solving this problem is "Predict Deman"

By predicting the demand of the potential consumer through the Artificial intelligence solution the retailer would be able to eliminate leftover out-of-stock scenarios because the adequate quantity of the products or demands will be provided thereby enhancing customers' experience arising from out-of-stock scenarios and reducing losses arising from the leftover.

5 0
3 years ago
What is information systems​
maxonik [38]

brainly.com/question/10887381

Answer:You need 7 bits to encode everything that could be typed on this keyboard.

Explanation:

The encoding of the QWERTY keyboard is based on the extended ASCII encoding. The "ASCII" code was created by the "American standards association" in 1963.The acronym of “American Standard Code for Information Interchange” is ASCII. ASCII is a 7-bit  code.

Further Explanation:

The QWERTY keyboard is the standard computer and typewriter keyboard design for Latin-script alphabets. The first six letters of the keyboard's upper row indicate its name.  Christopher Latham Sholes designed the layout of the keyboard for his "Type-Writer".  It was first mass-produced in 1874.

In QWERTY keyboard, extended American Standard for Information Interchange (ASCII) method is used for characters encoding. Alphabetical order of English language is the base of ASCII method of characters encoding.  

Learn More:

Learn more about QWERTY keyboard: brainly.com/question/649081; Answered by: Jessusulas

Learn more about ASCII: brainly.com/question/7851735; Answered by: LearnGrow

Keywords:

QWERTY keyboard, The encoding of the QWERTY keyboard, American Standard for Information Interchange, ASCII

6 0
3 years ago
Write an algorithm to find the maximum and minimum number from a given list of N numbers .Assume the list is not sorted
Y_Kistochka [10]
MaxNumber = 0
minNumber = INT_MAX

for n in list:
  if( n > maxNumber):
   maxNumber = n
  elif( n < minNumber ):
   minNumber = n
4 0
3 years ago
Other questions:
  • You have been hired to set up a network for XYZ Enterprises. What factors will you consider to determine the type of network nee
    7·2 answers
  • To enter a typed number into a cell, you press Tab or Backspace?​
    7·2 answers
  • Technician a says that the above illustration shows one method used to keep the chain tension tight in an indirect drive camshaf
    8·2 answers
  • Which option nukes your systemâall apps, programs, user files, user settingsâand presents a fresh installation of Windows?
    13·1 answer
  • To drive defensively means taking proactive measures to avoid accident situations regardless of their potential causes.
    6·2 answers
  • Agile Software Development is based on Select one: a. Iterative Development b. Both Incremental and Iterative Development c. Inc
    11·1 answer
  • The following are part of characteristics of a software requirement specification.
    6·1 answer
  • What is the output?
    5·1 answer
  • From which country samsung is​
    6·2 answers
  • Question 1 (True/False Worth 3 points)
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!