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
Hey I need help thank you.
inysia [295]

Please do not post the same question so many times. It makes it difficult for us to help other people. Thanks

6 0
3 years ago
Janet needs to assign a very important advertising account to one of her writers. First she reviewed each​ writer's work​ load,
S_A_V [24]

Answer:

D. systematic study

Explanation:

7 0
3 years ago
When evaluating where you want to attend college, it is good idea to narrow down your choices to?
Nataly [62]
The most important factor is considering the tuition. A lot of students experience problems regarding expensive student loans and gradually being in debt after school. To prevent this, keep you pool within your financial capability. Then, the basic information comes next, like the courses offered and the quality of education and training. 
8 0
3 years ago
A corporation purchased manufacturing equipment for $100,000, with an estimated useful life of 10 years and a salvage value of $
bulgar [2K]

Answer:

The second year’s depreciation for this equipment using the straight line method is 8,500

Explanation:

Depreciation: Depreciation is a decreasing value of the assets due to the tear & wear, obsolescence, usage,etc.

The formula to compute the depreciation under straight lie method is shown below:

= \dfrac{(original\ cost - salvage\ value)}{useful\ life}

= = \dfrac{(\$100,000 - \$15,000)}{10}

= $8,500

The depreciation amount under straight line method should remain same over the estimated useful life

So, the second year’s depreciation for this equipment is $8,500

6 0
3 years ago
Maria is a hard-working college sophomore. One Sunday, she decides to work nonstop until she has answered 100 practice problems
sdas [7]

Answer:

The correct answers are:

i. The marginal, or additional, gain from Maria’s first hour of work, from 8:00 AM to 9:00 AM, is <u>  40  </u> problems.

ii. The marginal gain from Maria’s third hour of work, from 10:00 AM to 11:00 AM, is <u>   20   </u> problems

iii. 2 hours working on problems, 2 hours reading (c)

Explanation:

i. The marginal gain from 8:00 AM to 9:00 AM is calculated thus:

work done at 8:00 AM = 0 problems

Work done at 9:00 AM = 40 problems

Marginal gain = (Work done at 9:00 AM) - (work done at 8:00) = 40 - 0 = 40 problems

ii. work done at 10:00 AM = 70 problems

work done at 11:00 AM = 90 problems

Marginal gain = 90 - 70 = 20 problems

iii. To get the best exam score, the most number of problems possible in total must be answered within the 4-hour period, and this is determined as follows:

we are told that Maria gets tired as time progresses and the number of questions answered reduces we notice the following numbers of questions answered in each hour:

8:00 AM to 9:00 AM = 40 - 0 = 40 problems (hour 1)

9:00 AM to 10:00 AM = 70 - 40 = 30 problems (hour 2)

10:00 AM to 11:00 AM = 90 - 70 = 20 problems (hour 3)

11:00 AM to Noon = 100 - 90 = 10 problems (hour 4)

Also, we are told that;

1 hour of reading = 25 problems

Comparing the reading and solving problems, we see that the number of problems solved in hour-1 and hour-2  (40 and 30 respectively) are more than the equivalent number of problems solved in reading for 1 hour, while hour-3 and hour-4 (20 and 10 respectively), have lesser equivalent number of problems each, than reading for one hour. Therefore to make the most out of the 4 hours, Maria will spend the first 2 hours solving problems and the next two hours reading, giving a total of: 40 + 30 + 25 + 25 = 120 problems solved.

4 0
3 years ago
Other questions:
  • o reduce its stock price, Shriver Food Systems, Inc., declared and issued a 100 percent stock dividend. The company has 800,000
    14·1 answer
  • A few years ago, in order to gain market share, Blackboard™, a well-known learning management system software company used by ma
    10·1 answer
  • It is the responsibility of the _____ to ensure that the proper agency is notified of flight termination
    15·1 answer
  • Dana is planning on renovating her kitchen. When she went into a home improvement store, she admired the various model kitchens
    7·1 answer
  • What is the formula for measuring the price elasticity of supply? Percentage change in quantity demanded/percentage change in in
    13·1 answer
  • This company reports only total factory overhead on the schedule of cost of goods manufactured and attaches a separate schedule
    9·1 answer
  • Suppose at the end of the meeting that Jack agrees to offer the restaurant buyout, including the non-competition agreement. Prio
    5·1 answer
  • Peck corporation, a foreign subsidiary was acquired by a U.S. corporation on January 1, 2020. Determine the exchange rate used t
    8·1 answer
  • Johnny Depp has just invested in a group of companies that are young and that he feels are going to have a large increase in pri
    11·1 answer
  • which of the following statements is most accurate about creating effective podcasts? a. podcast hosts should consider general a
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!