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
What are tariffs? What are some of the harmful effects of tariffs?
vodka [1.7K]
A tariff is a tax on exported goods, if a tariff is too high then it will increase the cost of the item so the people who are buying have to pay more.
5 0
3 years ago
Read 2 more answers
The actual cash received from cash sales was $36,006 and the amount indicated by the cash register total was $36,010. Journalize
andrezito [222]

Answer:

Cash shorting = 36,010 - 36,006 = $4

DR Cash                                                                  $36,006

     Cash Short and Over                                        $         4

     CR Sales                                                                            $36,010

There is a shortage of cash as the sales figure is more than the cash amount. The Cash Short and Over account will therefore be debited to reflect this expense.

7 0
3 years ago
Which individual can use the head of household filing status?
Lana71 [14]

Answer:

A. A married person with children

Explanation:

That person would be the head because he would be in charge.

8 0
3 years ago
Missy, age 30, has owned her principal residence (adjusted basis of $225,000) for five years. During the first three years of ow
vlada-n [284]

Answer:

The answer to the following question is attached within a word file.

Download docx
7 0
3 years ago
C. the "difference between growth and value shares involves a distinction based on book-to-market value. justify the low book-to
jekas [21]

Answer:

Explanation:

C. the "difference between growth and value shares involves a distinction based on book-to-market value. justify the low book-to-market ratios of growth shares versus high book-to-market ratios of value shares. (10 marks)

6 0
2 years ago
Other questions:
  • Ruth gives Seth a computer as a gift. Using the computer, Seth develops a new game, for which he obtains intellectual property p
    8·1 answer
  • Give some four examples of trade-offs when scarce resources are used.​
    5·1 answer
  • A recently opened car dealer uses an incentive compensation plan for its sales people. The dealer provides money to its salespeo
    10·1 answer
  • Oriole Company had $234,200 of net income in 2019 when the selling price per unit was $151, the variable costs per unit were $91
    9·1 answer
  • 3. Imagine that you are working at a clothing or grocery store, and answer the questions
    5·1 answer
  • Melinda is a very popular executive. She inspires her employees to follow a common vision, facilitates change, and creates a str
    13·1 answer
  • Geithner LLC patented a process it developed in the current year. The patent is expected to create benefits for Geithner over a
    9·1 answer
  • Super Smarts University has a sticker price of $45,000 per year. Kyle is applying there and uses their online net price calculat
    12·1 answer
  • A registered representative has left one firm to join another. Sometime later, the former employer discovers that some informati
    11·1 answer
  • You have just been elected to public office and you have been informed that the government does not have money to pay all of its
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!