
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Please make a searching and sorting
java program is below
![// method to search a String array for a name
public static int findName (String nameToFind, String array[])
f
int place= -1; // place is negative if not found
// loop through array
for (int i = 0; i < array.length; i++)
{
//check if name to find is equal to current array element.
if (nameToFind.equalsIgnoreCase (array [i]) == true)
{
place i // store location of name.
}
return place; // return location.
}// end findName method
String findMe; // string to store name to find
findMe JOptionPane.showInput Dialog ("Enter player to search");
int loc; // variable to store location
loc findName (findMe, playerNames); // call findName method with array and name.
if (loc < 0) // negative location means not found
{
JOptionPane.showMessageDialog (null, findMe + " not found");
}
else
(
JOptionPane.showMessageDialog (null, playerNames [loc] + " has " + playerGoals [loc] +
goals");](https://content.bartleby.com/qna-images/question/03735c08-776e-4821-b006-2a036c3fa4b2/385be180-e717-47ba-8934-e65a6ee12f67/wcy1ana_thumbnail.jpeg)
Transcribed Image Text:// method to search a String array for a name
public static int findName (String nameToFind, String array[])
f
int place= -1; // place is negative if not found
// loop through array
for (int i = 0; i < array.length; i++)
{
//check if name to find is equal to current array element.
if (nameToFind.equalsIgnoreCase (array [i]) == true)
{
place i // store location of name.
}
return place; // return location.
}// end findName method
String findMe; // string to store name to find
findMe JOptionPane.showInput Dialog ("Enter player to search");
int loc; // variable to store location
loc findName (findMe, playerNames); // call findName method with array and name.
if (loc < 0) // negative location means not found
{
JOptionPane.showMessageDialog (null, findMe + " not found");
}
else
(
JOptionPane.showMessageDialog (null, playerNames [loc] + " has " + playerGoals [loc] +
goals");
![// sort the arrays by increasing goals
// loop through the whole array
for (int i = 0; i < playerNames.length; i++)
(
//loop through to compare two elements next to
each other
for (int j = 0; j < playerNames.length 1; j++)
{
//compare one element to the next
if (playerGoals [j] > playerGoals [j+ 1])
{
// swap goals if not in increasing order
int tempGoals = playerGoals [j];
playerGoals [j] playerGoals [j+1];
playerGoals [j+1] = tempGoals;
// swap names to keep lists correct.
String tempNames playerNames [j];
playerNames [j] playerNames [j+1];
playerNames [j+1] = tempNames;
} // end if
}// end for j
}// end for i](https://content.bartleby.com/qna-images/question/03735c08-776e-4821-b006-2a036c3fa4b2/385be180-e717-47ba-8934-e65a6ee12f67/ddwbed_thumbnail.jpeg)
Transcribed Image Text:// sort the arrays by increasing goals
// loop through the whole array
for (int i = 0; i < playerNames.length; i++)
(
//loop through to compare two elements next to
each other
for (int j = 0; j < playerNames.length 1; j++)
{
//compare one element to the next
if (playerGoals [j] > playerGoals [j+ 1])
{
// swap goals if not in increasing order
int tempGoals = playerGoals [j];
playerGoals [j] playerGoals [j+1];
playerGoals [j+1] = tempGoals;
// swap names to keep lists correct.
String tempNames playerNames [j];
playerNames [j] playerNames [j+1];
playerNames [j+1] = tempNames;
} // end if
}// end for j
}// end for i
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps

Knowledge Booster
Similar questions
- 1. Write a program that draws various figures, as shown in Figure (a). The user selects a figure from a radio button and uses a check box to specify whether it is filled. Using Java programmingarrow_forwardJava - Smallest Numberarrow_forwardJAVA algorithm ur pseudo-code ,, top-down, stepwise refinement. Write a Java program.. Baker Co pays commision. Salesppl get $200 a wk nd 9% of their gross sales per wk. You’ve been supplied with a list of the items sold by each salesperson. The values of these items are in pic, app inputs one 1 sale ladys items sold for last wk and calculates and shows her earnings. She can sell any amntarrow_forward
- Write a pseudocode for each example ( a though e) , making sure your pseudocode is structured and accomplishes the same tasks as the flow chart segementarrow_forwardPlease help me in creating any of the games or applications below using java. Both the list of the games and applications and the requirements that the program must have are belowarrow_forwardWrite a python program which displays a simple menu as follows:Python ISBN Conversion Menu1. Verify the check digit of an ISBN-102. Verify the check digit of an ISBN-133. Convert an ISBN-10 to an ISBN-134. Convert an ISBN-13 to an ISBN-105. Exit Please remember to use what you have learned during the semester such as:• Functions and/or Value Returning Functions• If structures or logic structures IF/Elif/ELSE• Data structures i.e. File input/output• String manipulations i.e. string slicing and lists, etc.• Modules• Loops i.e. WHILE loops or FOR loops I already created the program by using Python, but here is what I need help with (in bold):• Reading and writing data to a file(s). In other words, have the program to read ISBNs from a file and store the correct results in a file as well.Can you include codes within my current program (included below) so that my program will read ISBNs from a file and store the correct results in a file as well? * Please make sure to use the Python program…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY