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
1. What is capital ?
Vlad1618 [11]
Capital is a different way to call Money
6 0
3 years ago
At which inventory level is operations management considered to be doing an excellent job?
Natalka [10]

operations management is considered to be doing a great job when you are able to lead your crew and make sure all of the inventory is in order.
8 0
3 years ago
Common stock, par $12 per share, 49,000 shares outstanding. Preferred stock, 8 percent, par $17.5 per share, 7,710 shares outsta
Vlad [161]

Answer:

<h2>a. The Preferred stock is noncumulative.</h2>

Preferred stock

= 7,710 * 17.5 * 8%

= $‭10,794‬

Per share

= 10,794/7,710

= $1.40

Common Shareholders.

= 63,800 - 10,794

= $‭53,006‬

Per share

= ‭53,006‬/49,000

= $1.08

<h2>b. Preferred stock is cumulative. </h2>

This means that if preferred dividends are not paid in a year, they will be accrued and paid when they can.

Preferred stock

= 7,710 * 3 years (2017,2018,2019)

= $‭23,130‬

Per share = 23,130/7,710

= $3

Common stock

= 63,800 - 23,130

= $‭40,670‬

Per share

= 40,670/49,000

= $0.83

c. Why were the dividends per share of common stock less for the cumulative preferred stock than the noncumulative preferred stock?

b. The dividends in arrears on the preferred stock had to be fulfilled before dividends could be paid for the current year.

7 0
3 years ago
How are payroll taxes different from personal income taxes?
marta [7]
D) They pay for specific social programs rather than general government activities.
5 0
3 years ago
A toy manufacturer has three different mechanisms (‘alternatives") that can be installed in a doll that it sells. The different
Wittaler [7]

Answer:

The electrical action has the better expected monetary value with 492,000

Explanation:

We will multiply the expected outcome by their probability then, we add them to get the expected monetary value per option:

\left[\begin{array}{ccccc}$WIND-UP&$Return&$Probability&$Weight\\$Light&325000&0.1&32500\\$Morerate&190000&0.3&57000\\$Heavy&170000&0.6&102000\\$Total&&1&191500\\\end{array}\right]

\left[\begin{array}{cccc}$PNEUMATIC&Return&Probability&Weight\\$Light&300000&0.1&30000\\$Morerate&420000&0.3&126000\\$Heavy&400000&0.6&240000\\$Total&&1&396000\\\end{array}\right]

\left[\begin{array}{cccc}$Electrical&Return&Probability&Weight\\$Light&-600000&0.1&-60000\\$Morerate&240000&0.3&72000\\$Heavy&800000&0.6&480000\\$Total&&1&492000\\\end{array}\right]

3 0
3 years ago
Other questions:
  • g Peng Company is considering an investment expected to generate an average net income after taxes of $2,700 for three years. Th
    11·1 answer
  • Ann wants to buy a building. The annual NOI for the building will be $165,000. She wants to get a 20 year interest only fixed ra
    14·1 answer
  • E3-17 (Algo) Calculating Equivalent Units, Unit Costs, and Cost Assigned (Weighted-Average Method) [LO 3-3] Vista Vacuum Company
    7·1 answer
  • The Absolute Zero Co. just issued a dividend of $3.40 per share on its common stock. The company is expected to maintain a const
    5·1 answer
  • When living off campus, one way to save money is to rent an apartment where:?
    5·1 answer
  • Companies HD and LD have the same total assets, sales, operating costs, and tax rates, and they pay the same interest rate on th
    14·1 answer
  • If sales revenue is $80 million and accounts receivable increased by $12 million, the amount of cash received from customers:
    15·1 answer
  • Determine which statement about the absolute value of the price elasticity of demand is correct. The price elasticity of demand
    11·1 answer
  • The Capitalist Mutual Fund's portfolio is valued at $77.7 million. The fund has liabilities of $5.5 million, and the investment
    15·1 answer
  • An increase in government spending raises income: a. and the interest rate in the short run, but leaves both unchanged in the lo
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!