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]
4 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]4 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
it is often said that managers often make decisions without all the necessary information. Why is this so?
Elena L [17]

Managers usually make decisions without all the necessary information because they are not aware of the alternatives that they've and aren't able to predict the consequences of the decision.

  • In management, decision-making is vital. Decision-making is important in the planning process. During planning, the manager decides on the goals that an organization wants to pursue.

  • In certain cases, a manager may not have all the required information regarding a particular issue but despite that still makes such decisions. Also, there are some decisions that require urgent attention, and delaying such decisions can further complicate such issues.

Read related link on:

brainly.com/question/9075718

8 0
3 years ago
The laser printer in your home office needs to be replaced. You have been using it to print the normal number of pages that resu
andriy [413]

Answer:

ink-jet printer.

Explanation:

The ink-jet printer is the printer that is cheaper also smaller at the same time it also used for printing the text documents and highly quality colored images so for printing the receipts from the online orders and for some letters the above printer should be used as the cost of the printer is low

So the same should be selected

4 0
3 years ago
Suppose a whale-watching trip in alaska costs orca-spotters tours $800 per run. each whale-watching trip can hold 25 tourists, m
zimovet [89]
<span>Well if they are trying to maximize profits then they need to charge more per seat. At 25 seats costing $32.00 per seat you will break even. If the price is not altered then they will not make a profit. I would up the price at least 30%-50% so that they will make a respectable amount of profit on each seat.</span>
4 0
3 years ago
Southeast Airline had retained earnings of $1.5 million, sales of $5 million and net income of $0.5 million this year. It also p
tatyana61 [14]

Answer:

$1.86 million

Explanation:

Given the above data, we can calculate the retained earning for next year to be;

Retained earning this year end = $1.5 million retained earning at the beginning + $0.5 million net income - $0.2 million dividends

= $1.8 million

8 0
3 years ago
todd, a sales representative, is facing the challenge stressor of trying to close a sale on a major account. during the meeting
lys-0071 [83]

Options :

A) be strongly motivated and perform well

B) be poorly motivated out of fear, and perform poorly

C) develop severe emotional symptoms of stress

D) develop severe physical symptoms of stress

Answer: A) be strongly motivated and perform well

Explanation: Stressors pertaining to business may be explained as those demands which a job or business requires of workers. The challenge stressor includes demands such as volume of chores or workload, time constraint and other factors which could be place added responsibility or burden on an individual. In most cases however, these responsibilities or burden usually acts to motivate the employee or business owner and in the long run aids personal and professional growth. In the scenario above, The challenge stressor which Todd is faced with is one which requires him to be on top and thus requires preparation so as to be able to perform well and not appear as a novice during the business meeting. Hence, this should motivate him and hence put up a good performance.

3 0
4 years ago
Other questions:
  • Mary and Ted are discussing starting a new business and are asking themselves a series of questions like, "What is the worst tha
    11·1 answer
  • The hospital where jack works has a step-by-step process for treating heart attack victims. this is an example of a(n) psycholog
    8·1 answer
  • HELP ASAP, CORRECT ANSWER GETS BRAINLIEST
    5·2 answers
  • Which of the following is correct: A. The post-closing trial balance will ensure the accounting equation is balanced at the end
    11·1 answer
  • At her new job, Nicole developed a supportive relationship with Sheila, who worked with the same real estate agency for several
    13·1 answer
  • Suppose the price of one share of a particular stock rose from $9.00 to $9.15 over the course of a year, and the stock paid a di
    12·1 answer
  • Which of the following is not true about a good resume?
    12·1 answer
  • Select the correct answer from each drop-down menu. [BLANK] is a tool of monetary policy in which the Federal Reserve buys and s
    9·2 answers
  • True or False: Living expenses aren't considered startup costs.
    6·2 answers
  • The ability of one person or nation to produce more of a good while using the same quantity of resources as another is called a(
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!