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
Aneli [31]
2 years ago
13

In java please

Computers and Technology
1 answer:
Sidana [21]2 years ago
7 0

Answer:

Explanation:

The following code is written in Java. It is a static method that takes in a String parameter and loops through the String array called arr comparing each element in the array with the word parameter that was passed. If it finds a match the method returns the index of that word, otherwise it will return -1

  public static int findString(String word){

               int index = -1;

               for (int x = 0; x < arr.length; x++) {

                       if (word == arr[x]) {

                               index = x;

                               break;

                       }

               }

               

               return index;

               

       }

You might be interested in
Design and implement a class Country that stores the name of the country, its population, its area, and the population density (
melomori [17]

Answer:

See explaination

Explanation:

Make use of Python programming language.

File: Country.py

class Country:

def __init__(self, n="", p=0, a=0):

""" Constructor """

self.name = n

self.population = p

self.area = a

self.pDensity = self.population / self.area

def getCountryName(self):

""" Getter method """

return self.name

def getPopulation(self):

""" Getter Method """

return self.population

def getArea(self):

""" Getter Method """

return self.area

def getPDensity(self):

""" Getter Method """

return self.pDensity

File: CountryInfo.py

from Country import *

# Opening file for reading

with open("d:\\Python\\data.txt", "r") as fp:

# List that hold countries

countryInfo = []

# Processing file line by line

for line in fp:

# Stripping spaces and new lines

line = line.strip()

# Splitting and creating object

cols = line.split('\t')

cols[1] = cols[1].replace(',', '')

cols[2] = cols[2].replace(',', '')

c = Country(cols[0], int(cols[1]), float(cols[2]))

countryInfo.append(c)

# Processing each countryInfo

largestPop = 0

largestArea = 0

largestPDensity = 0

# Iterating over list

for i in range(len(countryInfo)):

# Checking population

if countryInfo[i].getPopulation() > countryInfo[largestPop].getPopulation():

largestPop = i;

# Checking area

if countryInfo[i].getArea() > countryInfo[largestPop].getArea():

largestArea = i;

# Checking population density

if countryInfo[i].getPDensity() > countryInfo[largestPop].getPDensity():

largestPDensity = i;

print("\nLargest population: " + countryInfo[largestPop].getCountryName())

print("\nLargest area: " + countryInfo[largestArea].getCountryName())

print("\nLargest population density: " + countryInfo[largestPDensity].getCountryName() + "\n")

Please go to attachment for sample program run

4 0
3 years ago
Which one of these are a valid IPv4 address? Check all that apply.
Illusion [34]
The answer is C.54.45.43.54
6 0
2 years ago
What output is produced by the following code? Integer first = new Integer(7); Integer second = first; if (first == second) Syst
fenix001 [56]

Answer:

The correct output of this question is  "Sneezy Sleepy".

Explanation:

In the given code firstly we create the object of the integer class that is first in this we pass the integer value that is 7. Then we declare another second integer variable is this variable we pass object as a reference. Then we use the two conditional statements. In the first, if block we check that the object of the class is equal to the reference variable. If it is true it prints Sneezy. otherwise, it will print Grumpy. In second if block we check that the object of the class is equal to the reference variable. but in this time we the equals() function it is the same as(==). If the condition is true it prints Sleepy. otherwise, it will print Doc. So the output of the code is Sneezy Sleepy.

6 0
3 years ago
Which of the following is not an example malicious code<br> A.Trojan horse B.worm C.virus D.spygear
umka21 [38]
B would be the correct answer

7 0
3 years ago
Read 2 more answers
What is a quasi vpn?
Natasha2012 [34]

Answer:

i don't think there is such thing as a quasi vpn

Explanation:

6 0
2 years ago
Other questions:
  • What is the output of the second println statement in the main method? public class Foo { int i; static int s; public static voi
    14·1 answer
  • Which of the following is NOT one of the modules of a typical Decision Support System (DSS)? Select one: a. Customer information
    14·2 answers
  • Name three types of hard drives, along with its speed and size.
    8·1 answer
  • Study the images of two different fronts.
    7·2 answers
  • Scenario
    7·1 answer
  • Is there any quantum computer in India?​
    9·1 answer
  • 1. What are you going to do if someone ask for your personal information online?​
    12·2 answers
  • 15. Virus cannot infect files that are saved in i. USB ii. CD-ROMs iii. Memory card iv. All of them​
    14·2 answers
  • Which of the following is not an advanced strategy you may use to help you conduct a search on the Internet?
    15·2 answers
  • write an algorithm to determine a student's final grade and indicate whether it is passing or failing. the final grade is calcul
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!