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
Jefferson Co. uses the following standard to produce a single unit of its product: Variable overhead $6 (2 hrs. per unit @ $3/hr
tankabanditka [31]

Answer:

B. 6,000U

Explanation:

The total variable overhead variance shall be calculated using the following formula:

Variable overhead variance=(Actual units produced*Standard hours per unit* Standard rate per hour) - (Actual variable production overhead cost of actual production)

Standard rate per hour=$3

Standard hours per unit=2

Actual units produced=24,000

Actual variable production overhead cost of actual production=$150,000

Variable overhead variance=(24,000*2*3-150,000)

                                              =(144,000-150,000)

                                              =$6,000U

So the answer is B. 6,000U

7 0
4 years ago
Economic policies that attempt to benefit the poor by taxing and spending are referred to as ________.
anygoal [31]

Answer:

Fiscal policy

Explanation:

Describes changes to government spending and revenue behavior in an effort to influence the economy. By adjusting its level of spending and tax revenue, the government can affect economic outcomes by either increasing or decreasing economic activity.

3 0
2 years ago
Suppose the government places a 5 per unit tax on a good, what the surplus after this tax?<br>​
Wittaler [7]

Answer:

the surplus would be $10 after this tax

5 0
3 years ago
Assume Ford Motor Company is discussing new ways to recapitalize the firm and raise additional capital. Its current capital stru
AlladinOne [14]

Answer:

The correct answer is

D) 7.27%

good luck ❤

5 0
3 years ago
The scientific method ________. results in conclusions based on speculation cannot prove a hypothesis to be true results in the
AlladinOne [14]

Answer:

The correct answer is letter "B": cannot prove a hypothesis to be true.

Explanation:

The scientific method is the proper procedure or instrument of science to obtain an explanation of things. Thanks to the scientific method it is possible to manage, combine, and use those things. Besides, it allows us to prove if a hypothesis deserves to be considered a Law. Without proof, the scientific method cannot prove if a hypothesis is true.

8 0
3 years ago
Other questions:
  • When will the wages per hour go up to 11.00 dollars per hour in 2017?
    8·1 answer
  • At one time, AT&amp;T and T-Mobile wanted to merge but were prevented from doing so by the Justice Department. The government ma
    8·1 answer
  • Sara shouppe has invested $100,000 in an account at her local bank. the bank will pay her a constant amount each year for 6 year
    15·1 answer
  • Financial leverage: Group of answer choices is the ratio of a firm's revenues to its fixed expenses. is equal to the market valu
    15·1 answer
  • An employer instituted a wellness program for all employees. The wellness program includes an exercise facility and several pay
    8·1 answer
  • What is a major benefit sales people offer to their businesses?
    15·1 answer
  • Frank has an auto policy with a coverage limit of $30,000 and a deductible of $1,000. He gets into an accident and the damages t
    15·1 answer
  • Raymond Moss, vice president of Moss Auto Parts, gets an annual bonus of 15% of any income, before deducting bonus and income ta
    14·1 answer
  • If your employer offers a retirement plan, it should be the first plan that you consider because your employer
    13·1 answer
  • In terms of general value propositions, the Hawks are providing greater value with a ____________________ strategy.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!