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
k0ka [10]
3 years ago
12

Write the AddressList method newBusiness. This method searches addresses for an existing business with an identical address (i.e

. an address object for which street matches st and number matches no). If this is found, then the method updates the item in the list to an address with name nm, street st and number no. If no entry with a matching street and number exists, then the method adds a new address to the end of the list with name nm, street st and number no. The method should return the index on Addresses where the address has been updated or added.
Business
1 answer:
max2010maxim [7]3 years ago
5 0

Answer:

See explaination

Explanation:

// Address.java

public class Address {

/**

* The name of the business

*/

private String name;

/**

* The name of the street the business is on

*/

private String street;

/**

* The street number of the business

*/

private int number;

/**

* Constructs an Address that represents a business with name nm,

* at number no on the street st

*/

public Address(String nm, String st, int no)

{

name = nm;

street = st;

number = no;

}

/**

* Returns the name of the business

*/

public String getName()

{

return name;

}

/**

* Returns the name of the street on which the business is located

*/

public String getStreet()

{

return street;

}

/**

* Returns the street number of the business

*/

public int getNumber()

{

return number;

}

}

//end of Address.java

//AddressBook.java

import java.util.ArrayList;

import java.util.List;

public class AddressBook {

/**

* The list of business addresses. No two businesses in the list

* can have the same address (both the same street and street number)

*/

private List<Address> addresses;

/**

* Constructs an empty AddressBook

*/

public AddressBook()

{

addresses = new ArrayList<Address>();

}

/**

* atparam st the name of a street

* atreturn a list with the names of each business with an address on that street

*/

public List<String> onStreet(String st)

{

// create an empty output list of names of business

List<String> businessName = new ArrayList<String>();

// loop over the list of addresses

for(int i=0;i<addresses.size();i++)

{

// if ith street of address = nm, add the name of the business to the output list

if(addresses.get(i).getStreet().equalsIgnoreCase(st))

businessName.add(addresses.get(i).getName());

}

return businessName; // return the list

}

/**

* Searches for an existing business with an identical address (street and number

* both match). Updates the record to an address with name nm, street st and number no.

* If no entry already exists adds a new address to the end of the list with these parameters.

*

* atparam nm the name of the business

* atparam st the street the business is on

* atparam no the street number of the business

* atreturn the index of where the business address is on the list

*/

public int newBusiness(String nm, String st, int no)

{

// loop over the list of addresses

for(int i=0;i<addresses.size();i++)

{

// if ith index addresses match the street and number of the input st and no

if((addresses.get(i).getStreet().equalsIgnoreCase(st)) && (addresses.get(i).getNumber() == no))

{

addresses.remove(i); // remove the ith address from list

addresses.add(i, new Address(nm,st,no)); // add a new address with the input name, street and number at ith index

return i; // return the index i

}

}

// if no address match, add the business at the end of the list

addresses.add(new Address(nm,st,no));

return addresses.size()-1; // return the last index

}

}

//end of AddressBook.java

You might be interested in
You have been asked to give a presentation at a small college in Ireland on your latest research. You want the faculty and stude
musickatia [10]

give exiting details about your research

8 0
3 years ago
During a recession, what is one way governments try to encourage growth? by increasing unemployment benefits by stopping governm
storchak [24]
During a recession, the way that governments try to encourage growth is : increasing unemployment benefits

During a recession, a number of unemployment will rapidly increased ( almost a third of citizen could be jobless). In order to handle this, government could increase unemployment benefit so the unemployed people have enough to scrapped by until the recession is over or started a new business.
7 0
3 years ago
Read 2 more answers
Item
vodka [1.7K]

What Muhammad found unsatisfactory about the Certificate of deposit is that the return on the investment was too low.

Basically, a certificate of deposit is under a Short term investment instrument which yields low interest value for investors.

The Short term investment yields on investment are low because it is for short period of time and involves lesser risks. Other instruments under Short term investment includes Money market etc.

Therefore, the option C is correct because the Certificate of deposit was seen as unsatisfactory by Muhammad because the return on the investment was too low.

Learn more about this here

<em>brainly.com/question/6564414</em>

7 0
3 years ago
The Office of Management and Budget ______. Group of answer choices
Serga [27]

Answer Choices:

A. is staffed by accountants, economists,  tax lawyers

B. keeps Congress well informed on international  affairs

C. was created by Article III of the Constitution

D. consents to treaties and  trade agreements negotiated by the President

Answer:

A.

7 0
3 years ago
Read 2 more answers
Harrison Corp. wants to raise its level of service to enhance customer experience. The board of directors sent out an email cont
romanna [79]

Answer:

Downward communication

Explanation:

Downward communication in a formal structure is the flow of information in terms of orders, appreciation, encouragement from higher authority to subordinates across the organization.

Upward communication in the form of feedback and problems flow from lower level employees to upper level. Here, the board of directors are top level employees who have passed the message to the employees to raise the level of service. This is a form of downward communication.

4 0
3 years ago
Other questions:
  • The manager of your company's pension fund is compensated based entirely on fund performance; he earned over $1.2 million last y
    7·1 answer
  • Equipment was purchased for $160000. Freight charges amounted to $3000 and there was a cost of $14000 for building a foundation
    7·1 answer
  • Megan, a human resource manager, recently approved the hiring of five summer interns. She will use ________ to decide which depa
    14·1 answer
  • The primary advantage an entrepreneur gains by leasing rather than buying facilities is
    15·1 answer
  • Following the formation of a corporation, which of the following terms best describes the process by which the promoter is relea
    15·1 answer
  • Phillips NV produces DVD players and exports them to the United States. Last year the exchange rate was​ $1.25/euro and Phillips
    11·1 answer
  • Nick works as the manager of Franklin Financial Consultants. His role involves giving tips and helping employees with regard to
    5·2 answers
  • Artis Sales has two store locations. Store A has fixed costs of $145,000 per month and a variable cost ratio of 60%. Store B has
    12·1 answer
  • -PLEASE HELP!
    7·2 answers
  • Sunnyside Travel, Inc. is a travel agency that specializes in destination wedding vacation packages. It has packages ranging fro
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!