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
Knowing that a third party may use the information that Ray is providing, does Ray owe a duty of confidentiality to Onyx?
artcher [175]

Answer:

<em>B. Yes, although it may be breached in most states if there is a court order to do so.</em>

Explanation:

<em>Duty of confidentiality is a provision that has been put in place in most states, to enable clients open up freely if they need help. This allows professionals to take whatever actions necessary to carry out full service delivery when helping the client. </em>Some of these details include health status, a client-lawyer case story, a social media's access to users' personal details, etc. The law prohibits professionals from disclosing information made available to them by the client to a third party. This duty is held by many professional bodies like the medical body, legal body, among others. <em>This duty can be broken by law in situations where the client sues the professional, or when there is a legal court order to do so</em>.

3 0
3 years ago
Material and Labor Variances The following actual and standard cost data for direct material and direct labor relate to the prod
Damm [24]

Answer:

Materials:

price     800U

quantity 510 F

Labor:

rate          1,860 F

efficiency 1,740 U

Explanation:

DIRECT MATERIALS VARIANCES

(standard\:cost-actual\:cost) \times actual \: quantity= DM \: price \: variance

std cost           $5.10

actual cost  $5.30

quantity          4,000

(5.1 - 5.3) \times 4,000 = DM \: price \: variance

price variance  $(800.00)

(standard\:quantity-actual\:quantity) \times standard \: cost = DM \: quantity \: variance

std quantity 4000.00

actual quantity 3900.00

std cost  $5.10

(4,000 - 3,900) \times 5.1 = DM \: quantity \: variance

quantity variance  $510.00

DIRECT LABOR VARIANCES

(standard\:rate-actual\:rate) \times actual \: hours = DL \: rate \: variance

std rate  $8.70

actual rate  $8.40

actual hours 6,200

(8.7 - 8.4) \times 6,200 = DL \: rate \: variance

rate variance  $1,860.00

(standard\:hours-actual\:hours) \times standard \: rate = DL \: efficiency \: variance

std  hours 6000.00

actual hours 6200.00

std rate  $8.70

(6,000 - 6,200) \times 8.70 = DL \: efficiency \: variance

efficiency variance  $(1,740.00)

4 0
4 years ago
Which abbreviation correctly replaces the underlined word? this year the family reunion will be in november in cleveland.
Brums [2.3K]
The answer is:  [A]:  " Nov. "
________________________________________________________
4 0
3 years ago
The upper class makes up about 25 percent of the population in the United States. True or False
jeyben [28]
Yes that is correct :)
5 0
3 years ago
Read 2 more answers
Which of the following is not an example of a liability?
finlep [7]
D , because liability means to be responsible for something, especially by law.
3 0
3 years ago
Read 2 more answers
Other questions:
  • A _____ is a price reduction offered to a consumer, an industrial user, or a marketing intermediary in return for prompt payment
    12·1 answer
  • Elijah is a warehouse production manager and has been assigned a complex project that might result in lengthy delays. in order t
    9·1 answer
  • The annuity settlement option that pays out the highest monthly income for as long as the annuitant lives, and leaves no residua
    5·2 answers
  • Suppose a $1,000 bond pays $40 per year in interest. Instructions: In part a, round your response to one decimal place. In part
    5·1 answer
  • You know about computer security, ethnics and privacy
    9·1 answer
  • The production possibilities frontier shows the maximum possible output of a good within a specific economy. Please select the b
    11·1 answer
  • An increase in demand and a decrease in supply, will lead to a(n) ________ in equilibrium quantity and a(n) ________ in equilibr
    6·1 answer
  • Let's not do business with AVC Real Estate Company; they discount their commissions" is an example of what?a) Price fixingb) Boy
    8·1 answer
  • Which of the following statements about stocks is TRUE?
    12·1 answer
  • Which sector dominates developed economies such as the United States? In developed economies such as the United States, the sect
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!