Write a program that reads in 15 numbers in sorted order from the user (i.e. the user enters them in order) and stores them in a 1D array of size 15. Next, prompt the user for a number to search for in the array (i.e. the "target"). Then, print the array. Next, search the array using a linear search – printing out each of

Answers

Answer 1

Corrected Question

Write a program that reads in 15 numbers in sorted order from the user (i.e. the user enters them in order) and stores them in a 1D array of size 15. Next, prompt the user for a number to search for in the array (i.e. the "target"). Then, print the array. Next, search the array using a linear search – find the target element and printing out the target and its index as well as the entire array

Answer:

The solution is given in the explanation section

See detailed explanation of each step given as comments

Explanation:

import java.util.*;

class Main {

 public static void main(String[] args) {

   //Create the array of 15 elements

   int [] array = new int [15];

   //Create an object of the scanner class to receive user input

   Scanner in = new Scanner(System.in);

   //Prompt user to enter the values in sorted order

   //Using a for loop

   for (int i =0; i<array.length; i++){

         System.out.println("Enter the next element: In SORTED order please!");

         array[i] = in.nextInt();

   }

   System.out.println("All Fifteen element have been entered");

   // Ask the user for an element to be searched for

   //A target element

   System.out.println("Which element do you want to search for in the array");

   //Create the target element

   int target = in.nextInt();

   //Use a for loop to sequentially check each element in the array

   for(int i = 0; i<array.length; i++){

     if(array[i]==target){

       System.out.println(target+" is found at index "+i +" of the array");

     }

   }

       // Printout the entire array

   System.out.println(Arrays.toString(array));

 }

}


Related Questions

What are two examples of items in Outlook?

a task and a calendar entry
an e-mail message and an e-mail address
an e-mail address and a button
a button and a tool bar

Answers

Answer:

a task and a calendar entry

Explanation:

ITS RIGHT

Answer:

its A) a task and a calendar entry

Explanation:

correct on e2020

B1:B4 is a search table or a lookup value

Answers

Answer:

lookup value

Explanation:

the language is Java! please help

Answers

public class Drive {

   int miles;

   int gas;

   String carType;

   public String getGas(){

       return Integer.toBinaryString(gas);

   }

   public Drive(String driveCarType){

       carType = driveCarType;

   }

   public static void main(String [] args){

       System.out.println("Hello World!");

   }

   

}

I'm pretty new to Java myself, but I think this is what you wanted. I hope this helps!

5-5. Design an Ethernet network to connect a single client P C to a single server. Both the client and the server will connect to their workgroup switches via U T P. The two devices are 900 meters apart. They need to communicate at 800 M b p s. Your design will specify the locations of any switches and the transmission link between the switches.


5-6. Add to your design in the previous question. Add another client next to the first client. Both connect to the same switch. This second client will also communicate with the server and will also need 800 M b p s in transmission speed. Again, your design will specify the locations of switches and the transmission link between the switches.

Answers

Answer:

ok so u have take the 5 and put 6

Explanation:

5-5. Ethernet network design: UTP connections from client PC and server to workgroup switches, 900m fiber optic link between switches, 800 Mbps communication.

5-6. Additional client connects to the same switch, UTP connection, maintains existing fiber optic link, 800 Mbps communication with the server.

What is the explanation for this?

5-5. For connecting a single client PC to a single server, both located 900 meters apart and requiring communication at 800 Mbps, the following Ethernet network design can be implemented:

- Client PC and server connect to their respective workgroup switches via UTP.

- Use fiber optic cables for the 900-meter transmission link between the switches.

- Install switches at the client PC and server locations.

- Ensure that the switches support at least 1 Gbps Ethernet speeds to accommodate the required transmission speed.

5-6. In addition to the previous design, for adding another client next to the first client:

- Connect both clients to the same switch.

- Use UTP cables to connect the second client to the switch.

- Ensure the switch supports 1 Gbps Ethernet speeds.

- Maintain the existing fiber optic transmission link between the switches.

- The second client can also communicate with the server at the required 800 Mbps transmission speed.

Learn more about Network Design at:

https://brainly.com/question/7181203

#SPJ2

(1) Prompt the user to enter a string of their choosing. Output the string.
Ex: Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself.
(2) Complete the GetNumOfCharacters() function, which returns the number of characters in the user's string. Use a for loop in this function for practice. (2 pts)
(3) In main(), call the GetNumOfCharacters() function and then output the returned result. (1 pt) (4) Implement the OutputWithoutWhitespace() function. OutputWithoutWhitespace() outputs the string's characters except for whitespace (spaces, tabs). Note: A tab is '\t'. Call the OutputWithoutWhitespace() function in main(). (2 pts)
Ex: Enter a sentence or phrase: The only thing we have to fear is fear itself. You entered: The only thing we have to fear is fear itself. Number of characters: 46 String with no whitespace: The only thing we have to fear is fear itself.

Answers

Answer:

See solution below

See comments for explanations

Explanation:

import java.util.*;

class Main {

 public static void main(String[] args) {

   //PrompT the User to enter a String

   System.out.println("Enter a sentence or phrase: ");

   //Receiving the string entered with the Scanner Object

   Scanner input = new Scanner (System.in);

   String string_input = input.nextLine();

   //Print out string entered by user

   System.out.println("You entered: "+string_input);

   //Call the first method (GetNumOfCharacters)

   System.out.println("Number of characters: "+ GetNumOfCharacters(string_input));

   //Call the second method (OutputWithoutWhitespace)

   System.out.println("String with no whitespace: "+OutputWithoutWhitespace(string_input));

   }

 //Create the method GetNumOfCharacters

   public static int GetNumOfCharacters (String word) {

   //Variable to hold number of characters

   int noOfCharactersCount = 0;

   //Use a for loop to iterate the entire string

   for(int i = 0; i< word.length(); i++){

     //Increase th number of characters each time

     noOfCharactersCount++;

   }

   return noOfCharactersCount;

 }

 //Creating the OutputWithoutWhitespace() method

 //This method will remove all tabs and spaces from the original string

 public static String OutputWithoutWhitespace(String word){

   //Use the replaceAll all method of strings to replace all whitespaces

   String stringWithoutWhiteSpace = word.replaceAll(" ","");

   return stringWithoutWhiteSpace;

 }

}

What is his resolution amount

Answers

I think it’s 92 I mean yh

On what date was jschlatt originally added to the dreamsmp server, and on which date was his second appearance on the server?

Answers

since this has already been answered, who is your favorite SMP character?

mines Wilbur/ Ghostbur

some people will disagree with me but jshlatt is one of my favorite characters on the dream smp . But my all time favorite characters is ALL of Wilbur's characters

Write a program that reads in 10 numbers from the user and stores them in a 1D array of size 10. Then, write BubbleSort to sort that array – continuously pushing the largest elements to the right side

Answers

Answer:

The solution is provided in the explanation section.

Detailed explanation is provided using comments within the code

Explanation:

import java.util.*;

public class Main {

//The Bubble sort method

public static void bb_Sort(int[] arr) {  

   int n = 10; //Length of array  

   int temp = 0; // create a temporal variable  

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

         for(int j=1; j < (n-i); j++){  

           if(arr[j-1] > arr[j]){  

               // The bubble sort algorithm swaps elements  

               temp = arr[j-1];  

               arr[j-1] = arr[j];  

               arr[j] = temp;  

             }  

         }            

         }  

        }

 public static void main(String[] args) {

   //declaring the array of integers

   int [] array = new int[10];

   //Prompt user to add elements into the array

   Scanner in = new Scanner(System.in);

   //Use for loop to receive all 10 elements

   for(int i = 0; i<array.length; i++){

     System.out.println("Enter the next array Element");

     array[i] = in.nextInt();

   }

   //Print the array elements before bubble sort

   System.out.println("The Array before bubble sort");

   System.out.println(Arrays.toString(array));

   //Call bubble sort method

   bb_Sort(array);  

               

   System.out.println("Array After Bubble Sort");  

   System.out.println(Arrays.toString(array));

 }

}

What is the maximum number of VLANs that can be configured on a switch supporting the 802.1Q protocol? Why?

Answers

Answer:

4096 VLANs

Explanation:

A VLAN (virtual LAN) is a group of devices on one or more LAN connected to each other without physical connections. VLANs help reduce collisions.

An 802.1Q Ethernet frame header has VLAN ID of 12 bit VLAN field. Hence the maximum number of possible VLAN ID is 4096 (2¹²).  This means that a switch supporting the 802.1Q protocol can have a maximum of 4096 VLANs

A lot of VLANs ID are supported by a switch. The maximum number of VLANs that can be configured on a switch supporting the 802.1Q protocol is 4,094 VLANS.

All the VLAN needs an ID that is given by the VID field as stated in the IEEE 802.1Q specification. The VID field is known to be of  12 bits giving a total of 4,096 combinations.

But that of 0x000 and 0xFFF are set apart. This therefore makes or leaves it as 4,094 possible VLANS limits. Under IEEE 802.1Q, the maximum number of VLANs that is found on an Ethernet network is 4,094.

Learn more about VLANs from

https://brainly.com/question/25867685

Write code that prints: Ready! numVal ... 2 1 Start! Your code should contain a for loop. Print a newline after each number and after each line of text Ex: numVal

Answers

Answer:

Written in Python

numVal = int(input("Input: "))

for i in range(numVal,0,-1):

    print(i)

print("Ready!")

Explanation:

This line prompts user for numVal

numVal = int(input("Input: "))

This line iterates from numVal to 1

for i in range(numVal,0,-1):

This line prints digits in descending order

    print(i)

This line prints the string "Ready!"

print("Ready!")

Other Questions
4/-7 + -6/5 In simplest form An).is anything that increases the chances of an unhealthy outcome.A. risk factorB. action planC. health continuumD. habit what is one second time ? In "A Warning Against Passion," what does Bront say can happen if a woman loves too much?a.she will go insanec.the man can begin to neglect herb.she will appear to be weakd.none of these Which is the IUPAC name for NO?nitric oxidebinitrogen oxidedinitrogen dioxidenitrogen monoxide There are 16 boys and 20 girls in a class. What part of the class is boys? What part girls? A taxi cab in Myrtle Beach charges $2 per mile and $1 for every person. If a taxi cab ride for two people costs $12 how far will the cab travel? Which of these describes a result of the Proclamation of 1763? 14. Craig jogs 12 km in 1 h. If he jogs at thesame rate, how long will it take him to jog18 km? A legal order for an investigation into whether a person who is arrested has been imprisoned legally defines what? RiDdLE oF ThE DaY: PaRt 2- Mr.White had been missing and the only evidence he left behind was a paper that said "The first of July, the fourth of January, the first of December and the eighth of February" the police questioned the people that were in the house at that time. Judy said she was at her parents house, Logan was Mr.Whites secretary said he was working on a report for his boss and haven't left his room and Rose, Mr. Whites daughter said she was having guest and never left the living room. Can you crack the case? people hugged, the less likely they were to get sick, evenamong individuals who frequently had tense interactions. In other words, both social support and hugging prevented against illness. The same lead researcher has previously shown that the more diverse types of social ties a person has, such as with friends, family, coworkers, and community, the less susceptible to colds they are.The phrase "friends, familycoworkers, and community" 53-54) primarily serves to B. clarity that only some social connections are beneficial to health. A. Illustrate the kinds of social ties to which the author is referring C. describe the groups of participants in the researcher's previous study D. provide examples of people from whom readers might be exposed to Mness . ITS SUPER EASY PLEASE HELP ITS DUE IN AN HOUR PLEASEEEEEEEEEEEEEEEEEEEEEE Ms. Howard wrote a test. Part A had true/false questions, each worth points. Part B had multiple choice questions, each worth points. She made the number of points for Part A equal the number of points for Part B. It was the least number of points for which this was possible. Soft skills 2 sentences that will help - What group of citizens did not benefit from the 15th Amendment and why? Explain your answer in full sentences.)help me What is StartFraction 5 Over 8 EndFraction divided by One-fourth? Which statement is true about the transformation? PLEASE HELP!! Please show me work also! MYFAVORITE SUbject anessay about100wordsMi