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
77julia77 [94]
3 years ago
12

Write a java program to create an array of 5 numbers. accept a number and search for that number in the array using linear searc

h. Display the appropriate message
Computers and Technology
1 answer:
yKpoI14uk [10]3 years ago
5 0

Answer:

import java.util.Random;

public class brainly {

   public static void main(String[] args) {

       int[] test_list = create_array(5);

       int target = 2; // change all of these

       int index = search(test_list, target);

       if (index == -1) {

           System.out.println("Target " + target + " not found.");

       }

       else {

           System.out.println("Target " + target + " found at index " + index);

       }

   }

   public static int[] create_array(int num) {

       Random rand = new Random();

       int[] list = new int[num];

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

           int rand_int = rand.nextInt(num); // change this to what you want

           list[i] = rand_int;

           System.out.print(rand_int);

       }

       System.out.println("\n");

       return list;

   }

 

   public static int search(int arr[], int x) {  

       int n = arr.length;  

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

           if(arr[i] == x)  

               return i;  

       }  

       return -1;  

   }  

}

Explanation:

First off, your question is very vague, anyway, here is my interpretation.

The method create_array creates an array with the specified length.

It creates an array out of random numbers from 0 to the length.

The method search method is a simple linear search, stepping by one each cycle.

I honestly have no idea what the question is, but I added an attachment of the code.

Download java
You might be interested in
Software is the brain of computer. Explain this starement
Annette [7]

here you go

i hope this helps you

5 0
3 years ago
What are the functions of an input device​
marshall27 [118]

Answer:

To feed the computer with data/instructions

6 0
3 years ago
Read 2 more answers
__ is a process of adding details to a model to make it less abstract.
koban [17]

Answer:refinement

Explanation:

5 0
3 years ago
Read 2 more answers
Saving a file as a new filename can be accomplished through the Save As dialog box.
Arisa [49]

Answer:

True.

Explanation:

A dialog box is a small window that serves as a controlling element in computers. The name dialog box is suggestive that it is a window that helps the user to communicate and response with an answer.

There are several types of common dialog box such as open dialog box, save as dialog box, print dialog box, etc.

Save as dialog box is a window that enables the user to save a file with a new name and new location. Save as dialog box can be opened by going to the File menu and click Save as. After the Save as dialog box appears, the user is able to change file name, location, etc.

Thus the statement is true.

4 0
4 years ago
Explain why cloud computing can be more complex than a traditional approach.
sp2606 [1]

Cloud computing is more complex than traditional approach due to the following reasons.

Explanation:

1.Cost Savings and Total Cost of Ownership. When you move to cloud computing you tend to save money in several ways in comparison to traditional IT, including the reduction of in-house equipment and infrastructure.

2.Dissatisfaction in Traditional IT. Many companies are frustrated with the negatives that come with traditional IT, such as poor data backup, managing and maintaining your own hardware, and lack of disaster recovery options.

3.Time to Value and Ease of Implementation. Since you don’t have to spend time configuring hardware, maintain systems, and patching software, you can invest your resources elsewhere.

4.Access to Emerging Technology. Much like a car, the minute you purchase on-premise hardware and software, it immediately starts to age. You can access the latest and greatest innovations with a cloud provider who has more purchasing power and stays up-to-date with available solutions. Also, as new innovations are released, they become less likely to integrate with legacy solutions that are often inflexible. Instead, cloud-first development is coming to the forefront.

5.Using Hybrid to Optimize your Operations. Some organizations take the use of the cloud even further by using multiple clouds simultaneously, thus giving them even more agility. Workloads are placed where they perform best, and where costs are most efficient.

5 0
3 years ago
Other questions:
  • What is an examlple of cyberbullying
    5·1 answer
  • Word processing software allows users to do which of the following:
    10·1 answer
  • A project team was researching the risks involved in setting up a computer system. They decide to go ahead with their plan, rega
    7·1 answer
  • What’s the difference between the logical and physical structure of a file? What are the advantages of not having an application
    15·1 answer
  • The ____ code sets the style so that the web page element remains constant and does not move.
    11·1 answer
  • Discuss the factors which cause imbalance in the environment.
    8·1 answer
  • What is an example of using the internet of things (iot) to deliver innovative cloud-based solutions to customers?
    11·1 answer
  • Universal containers wants internal support requests to be directed to any of the IT reps. They want external support requests t
    9·1 answer
  • When conducting memory and recall tests, some people make an effort to normalize memories by not reporting extreme cases. this l
    12·1 answer
  • 1
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!