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
Which account is an example of a contra-expense account?
Iteru [2.4K]
Its an expense account that follows credit, not debit
5 0
2 years ago
Read 2 more answers
You are an experienced manager, and you fortunately have the ability to use all four managerial styles: directing, coaching, sup
nikitadnepr [17]

Answer:

B) You should sit down with the programmers and give them information about how to deal with bugs as they occur.

Explanation:

Options:

A. You should focus on reassuring the programmers: give them pep talks and tell them you know that they have the skills to accomplish the job.

B. You should sit down with the programmers and give them information about how to deal with bugs as they occur. But make sure that you set aside time for extensive praise and support.

C. You should tell your programmers that the project is theirs—they can do what they want with it as long as they have something to show you in two months.

D. You should continue the focus on teaching your employees how to program, especially showing them new ways of increasing efficiency. The bugs will take care of themselves.

B) is correct answer

(Hope this helps can I pls have brainlsit (crown)☺️)

4 0
2 years ago
Angel's bank statement shows a closing balance of $109.22. There are no outstanding checks or deposits. Her checkbook shows a ba
Wittaler [7]
The answer to the question is D

7 0
3 years ago
Assume a systems development project effort calculation determines that the system will require 240 function points. if the deve
kakasveta [241]

The guess the correct answer is much less.

Assume a systems development project effort calculation determines that the system will require 240 function points. If the developers choose to implement this system in the C programming language, approximately 31,200 lines of code will have to be written. If the developers choose Visual Basic to implement the system, the number of lines of code will be much less.

4 0
3 years ago
A new restaurant has introduced a wildly popular macaroni and cheese dish made with goat cheese. however, at approximately the s
bixtya [17]

How do the price and quantity of goat cheese change? The price of goat cheese will likely rise because there is less being produced and able to be consumed. The quantity of goat cheese is not able to be determined by the information provided in the question.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Oriole Company purchased a building on January 2 by signing a long-term $482000 mortgage with monthly payments of $5300. The mor
    5·1 answer
  • Tom told his son, bobby, to go out and rake leaves. bobby went outside but raked pretty slowly (one bag in 2 hours). tom told bo
    10·1 answer
  • Bank account register definition
    6·1 answer
  • tahir owns and operates a gym. In 2020, he purchased and placed the following new assets into service for his business: March 17
    15·1 answer
  • Intel corporation created the Intel Inside campaign to make consumers aware that an important component of any computer is the q
    9·2 answers
  • For a manufacturing company, selling price for an item is $472.00 per Unit, Variable cost is $235.00 per Unit, rent is $7,880.00
    13·1 answer
  • Laura and Bryce both want to be able to forward receipts to QuickBooks Online to take advantage of the Receipt Capture feature.
    7·1 answer
  • Which of the following statements is true of lead qualification? Group of answer choices It refers to a process that describes t
    15·1 answer
  • The use of a variety of marketing channels to ensure maximum distribution is best called _______.
    6·1 answer
  • Which of the following is an example of internal data in a marketing
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!