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
Choose the correct alternative regarding tax revenue:
insens350 [35]

The correct alternative regarding tax revenue:

<u>B-Personal income tax is currently the largest source of government revenue in South Africa.</u>

<u>Direct </u><u>Taxes</u>

  • it is levied on earnings and activities conducted.
  • the burden of tax cannot be shifted in case of direct tax.
  • it is paid directly by individual concerned.
  • it is paid after the income reaches in the hands of the taxpayer
  • Tax collection is difficult.
  • instance income tax, wealth tax etc.

<u>Indirect </u><u>Taxes</u>

  • it is levied on product or services.
  • the burden of tax shifted for indirect taxes
  • It is paid by way of one man or woman however he recovers the same from another person i.e. person who actually bear the tax ultimate consumer.
  • it is paid before goods/service reaches the taxpayer.
  • Tax collection is exceptionally easier
  • Example GST, excise duty custom duty sale tax carrier tax

Learn more about Tax brainly.com/question/16423331

#SPJ9

5 0
2 years ago
In some developing countries, children work in factories when they are 8 or 9 years old. The United States has strict child labo
Katena32 [7]

Answer:

b. They reflect the laws and regulations that affect social and economic behavior.

Explanation:

Morals are not universal and vary greatly depending on the underlying culture and religion. Even still in each civilization, there are many grey areas in the concept of morals. One thing that seems to be constant is that they reflect the laws and regulations that affect social and economic behavior. In this scenario, some developing countries believe that using children as a cheaper form of labor is fine since the children are getting paid and therefore, there are no laws prohibiting this action so people see it as morally correct. While other countries that see it as morally wrong have laws and regulations to prevent people from performing such actions. These laws and regulations are a form of dictating social and economic behavior by stating that it is morally wrong.

3 0
3 years ago
In a 100-percent reserve banking system, if people decided to decrease the amount of currency they held by increasing the amount
MariettaO [177]

Answer:

a M1 would not change.

Explanation:

the checkable deposits are part of M1 as well as the currency and coins. Therefore, a component of M1 decrease (currency) while another of M1 (checkable deposits) increase.

As the banking system works with a 100-percent required reserve there is no multiplier effect from the deposit therefore M1 do not change.

8 0
4 years ago
Shawna wins the lottery and her income increases by 60 percent. she used to buy 10 pints of cottage cheese per month and now she
Dmitriy789 [7]

Answer: Her income elasticity of demand for cottage cheese is <em><u>0.3333</u></em> making it a <em><u>normal and necessary</u></em> good.

The income elasticity  of demand is given by :

\mathbf{YED = \frac{percentage change in demand}{percentage change in income}}

The percentage change in income is given as 60%. We calculate the percentage change in quantity demanded as follows:

\mathbf{percentage change in quantity demanded = \frac{Q_{1}-Q_{0}}{Q_{0}}}

\mathbf{percentage change in quantity demanded = \frac{12-10}{10}}

\mathbf{percentage change in quantity demanded = 0.2}\\

Substituting the value above in the income elasticity demand formula we get,

\mathbf{YED = \frac{0.20}{0.60}}

<u>YED = 0.33333</u>

Since the income elasticity is positive, and since Shawna buys more cottage cheese after an increase in income, we can classify this good as a normal good.

Since the income elasticity is between 0 and 1 we can also conclude that cottage cheese is also a essential good or a necessity.

7 0
3 years ago
Productivity is the combination of
BigorU [14]
Efficiency i believe <span />
5 0
3 years ago
Read 2 more answers
Other questions:
  • An event that must occur in order for a party's duty to arise is called a(n) ________________.
    13·1 answer
  • What are six steps in developing your brand's marketing message?
    9·1 answer
  • Kota Toy Corporation manufactures lizard dolls in two departments, Molding and Assembly. In the Molding Department, plastic is i
    12·1 answer
  • The motivating force behind an increase in supply in a long-run adjustment to equilibrium is
    6·1 answer
  • Two voters, al and bill, are each choosing between one of three candidates—1, 2, and 3—who are running for city council. an expe
    12·1 answer
  • Why does a diverse and inclusive workforce benefit a firm supporting a global market?
    15·1 answer
  • Based on the position you are interested in, please describe your sales or retention style.
    14·1 answer
  • Use the following information to answer the questions:
    6·1 answer
  • First National Bank loans Mike’s Shoe Store $100,000 for remodeling. On their balance sheets, this loan is an asset for Mike’s S
    12·1 answer
  • Which of the following is true?
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!