Questions
The game of Nim. This is a well-known game with a number of variants. The following...

The game of Nim. This is a well-known game with a number of variants. The following variant has an interesting winning strategy. Two players alternately take marbles from a pile. In each move, a player chooses how many marbles to take. The player must take at least one but at most half of the marbles. Then the other player takes a turn. The player who takes the last marble loses.

Write a program in which the computer plays against a human opponent. Generate a random integer between 10 and 100 to denote the initial size of the pile. Generate a random integer between 0 and 1 to decide whether the computer or the human takes the first turn. Generate a random integer between 0 and 1 to decide whether the computer plays smart or stupid. In stupid mode, the computer simply takes a random legal value (between 1 and n/2) from the pile whenever it has a turn. In smart mode the computer takes off enough marbles to make the size of the pile a power of two minus 1 - that is, 3, 7, 15, 31, or 63. That is always a legal move, except when the size of the pile is currently one less than a power of two. In that case, the computer makes a random legal move.

You will note that the computer cannot be beaten in smart mode when it has the first move unless the pile size happens to be 15, 31, or 63. Of course, a human player who has the first turn and knows the winning strategy can win against the computer.

Make sure your program tells the user whether the computer played in smart or stupid mode.

Your program will need to use both decisions (if statements) and loops.

method returns a double value >= 0.0 and < 1.0. To get a random integer between two integer values (Min and Max) use:

Min + (int)(Math.random() * ((Max - Min) + 1))

Write pseudocode and/or a flow chart before you try to write this program. As you write your program, a good practice would be to write and test it in parts. For example, generate the initial size of the pile, which player goes first, and what mode the computer plays in and output without actually playing the game. Then play one round and end the game, etc.

Submit:
Pseudocode for your solution.
Your Java code as a .java file.

In: Computer Science

Debt: 4,000, 7% semiannual coupon bonds outstanding, $1,000 par value, 18 years to maturity, selling for...

Debt: 4,000, 7% semiannual coupon bonds outstanding, $1,000 par value, 18 years to maturity, selling for 102 percent of par; the bonds make semiannual payments.

Preferred Stock:  10,000 outstanding with par value of $100 and a market value of 105 and $10 annual dividend.

Common Stock: 84,000 shares outstanding, selling for $56 per share, the beta is 2.08

The market risk premium is 5.5%, the risk free rate is 3.5% and Huntington’s tax rate is 32%.

Huntington Power Co. is evaluating two mutually exclusive project that is somewhat riskier than the usual project the firm undertakes; management uses the subjective approach and decided to apply an adjustment factor of +2.1% to the cost of capital for both projects.

Project A is a five-year project that requires an initial fixed asset investment of $2.4 million. The fixed asset falls into the five-year MACRS class. The project is estimated to generate $2,050,000 in annual sales, with costs of $950,000. The project requires an initial investment in net working capital of $285,000 and the fixed asset will have a market value of $225,000 at the end of five years when the project is terminated.

Project B requires an initial fixed asset investment of $1.0 million. The marketing department predicts that sales related to the project will be $920,000 per year for the next five years, after which the market will cease to exist. The machine will be depreciateddown to zero over four-year using the straight-line method (depreciable life 4 years while economic life 5 years). Cost of goods sold and operating expenses related to the project are predicted to be 25 percent of sales.  The project will also require an addition to net working capital of $150,000 immediately. The asset is expected to have a market value of $120,000 at the end of five years when the project is terminated.

Use the following rates for 5-year MACRS: 20%, 32%, 19.2%, 11.52%, 11.52%, and 5.76%

  1. Calculate WACC for the firm.
  2. What is the appropriate discount rate for project A and project B (Risk adjusted rate)?
  3. Calculate project A’s cash flows for years 0-5
  4. Calculate NPV, IRR and PI for project A
  5. Calculate project B’s cash flows for year 0-5
  6. Calculate NPV, IRR and PI for project B
  7. Which project should be accepted if any and why?
  8. What is the exact NPV profile’s crossover rate (incremental IRR)?

In: Finance

You have just started a new job and your employer has enrolled you in KiwiSaver. This...

You have just started a new job and your employer has enrolled you in KiwiSaver.

This is the first time you have been enrolled in KiwiSaver and you decide not to “opt out”.

You are interested in estimating how much your KiwiSaver fund could be worth when you retire.

You make the following assumptions:

• You have just turned 30 and will retire in exactly 35 years when you are 65.

• Your salary is $50,000 this year and you expect this to increase by 3% every year.

• You can choose to contribute either 3% or 8% of your salary into your KiwiSaver fund each year. https://www.kiwisaver.govt.nz/already/contributions/you/amount/

• Your employer must contribute 3% of your pay into your KiwiSaver fund each year. https://www.kiwisaver.govt.nz/already/contributions/employers/ You can ignore any tax implications and assume your account receives the full 3%. (KIWI SAVER ACC)

• You will be entitled to the annual member tax credit of $521.43 which will be credited into your KiwiSaver fund at the end of every year. https://www.kiwisaver.govt.nz/new/benefits/mtc/

• Your KiwiSaver fund will invest in a diversified portfolio of assets to earn a return on your investment. Of course, there is uncertainty around the actual annual rate of return that your fund will earn over the 35 years but you decide that 6% and 12% represent a good range of potential rates of return to conduct your analysis on.

• Regardless of the return earned, the manager of your KiwiSaver fund will charge a management fee of 1.0% at the end of each year, based on the opening balance of your fund each year.

• You will make no withdrawals or additional contributions (other than those mentioned above) to your fund until you retire in 35 years.

• For simplicity, assume that all contributions to your KiwiSaver fund are made once per year, at the end of the year. The first lot of contributions will be made in one year from today.

Construct a spreadsheet that will allow you to answer the following questions on Canvas.

It is calculated that your expected annual salary when you are 45 years old is $77,898

  1. How much will be in your KiwiSaver account at the start of that year if you contributed 3% of your salary and the fund earned 6%p.a.?

In: Finance

Exercise 1: Write an XML document describing the exercises in this document: the root element is...

Exercise 1:

Write an XML document describing the exercises in this document: the root element is <exercises>. The root has an attribute number that has value 1. The root element has three child elements; <date> that contains as text the date of the exercise, and two <item> elements for the first two exercises (1--2). Write some text in the <item> elements.

Exercise 2:

Write an XML document describing a person: name, occupation, address and hobbies. Please do not use your own information, you can use fake data. Decide on suitable element names and nesting. Check your document for well-formedness.

Exercise 3:

Draw a tree that represents the XML document you created in task 2.

Exercise 4:

This is the books.xml file

<?xml version='1.0'?>
<!-- This file represents a fragment of a book store inventory database -->
<bookstore>

<book genre="autobiography" publicationdate="1981" ISBN="1-861003-11-0">

<title>The Autobiography of Benjamin Franklin</title>
<author>

<first-name>Benjamin</first-name>
<last-name>Franklin</last-name>

</author>

<price>8.99</price>

</book>

<book genre="novel" publicationdate="1967" ISBN="0-201-63361-2">

<title>The Confidence Man</title>

<author>

<first-name>Herman</first-name>
<last-name>Melville</last-name>

</author>

<price>11.99</price>

</book>

<book genre="philosophy" publicationdate="1991" ISBN="1-861001-57-6">

<title>The Gorgias</title>
<author>

<name>Plato</name>

</author>

<price>9.99</price>

</book>

</bookstore>

Using books.xml as a model, create a small xml file for a student's program of study form called programOfStudy.xml. It should capture the following data:

  • In the Fall 2008 semester the student plans to take two classes to satisfy her General Education requirements, PHIL 101 to satisfy Goal 8 and ECON 201 to satisfy Goal 11. She also has to take one core course, MGT 217, and two major courses, CIS 120 and CIS 403.
  • In the Spring 2009 semester she plans to take two additional core courses, MGT 261 and MKTG 325, as well as three major courses, CIS 220, CIS 407, and CIS 490.

In: Computer Science

# Problem Description Given a directed graph G = (V, E), find the number of connected...

# Problem Description

Given a directed graph G = (V, E), find the number of connected components in G.

# Input

The graph has `n` vertices and `m` edges.
There are m + 1 lines, the first line gives two numbers `n` and `m`, describing the number of vertices and edges. Each of the following lines contains two numbers `a` and `b` meaning there is an edge (a,b) belong to E. All the numbers in a line are separated by space. (`1 <= a,b <= n`)

You can assume that 2 <= n <= 10000, 1 <= m <= 50000.

Your code should read the input from standard input (e.g.
using functions `input()/raw_input()` in Python and `cin/scanf` in C++).

# Output

One number representing the number of connected components in the graph.


Your code should write the output to standard output (e.g. using functions `print` in Python and `cout/printf` in C++).

# Requirement

Your algorithm should run in O(|V| + |E|) time.

Time limtation: 5 seconds.

Memory limitation: 1.0 GB.

# Environment

Your code will be running on Ubuntu 18.04.5.

Now only accept C++ and Python2/Python3 code, g++ version 7.5.0 and Python versions are Python 2.7.17 and Python 3.6.9.

# Examples and Testing

Some examples (e.g., input-x.txt and output-x.txt, x = 1, 2) are provided.
A figure corresponding input-1 can be found in this repo too.
For Python code, try the following to test your code
```
python ./solution.py < input-x.txt > my-output-x.txt
```
For C++ code, try the following to test your code
```
g++ -o mybinary solution.cpp
./mybinary < input-x.txt > my-output-x.txt
```

Your output `my-output-x.txt` needs to be *match exactly* to the given `output-x.txt`.
On Unix-based systems you can use `diff` to compare them:
```
diff my-output-x.txt output-x.txt
```
On Windows you can use `fc` to compare them:
```
fc my-output-x.txt output-x.txt
```

# Submission

If you want to upload a single file, make sure the file is named as `solution.py` (for Python) or `solution.cpp` (for C++).
If you submit via GitHub, make sure your file is located in directory `assignment3/problem1/solution.py` (for Python) or `assignment3/problem1/solution.cpp` (for C++).

# Hints

Use adjacency list to store all the edges.

In: Computer Science

Please use python: # Problem Description Given a directed graph G = (V, E), find the...

Please use python:

# Problem Description

Given a directed graph G = (V, E), find the number of connected components in G.

# Input

The graph has `n` vertices and `m` edges.
There are m + 1 lines, the first line gives two numbers `n` and `m`, describing the number of vertices and edges. Each of the following lines contains two numbers `a` and `b` meaning there is an edge (a,b) belong to E. All the numbers in a line are separated by space. (`1 <= a,b <= n`)

You can assume that 2 <= n <= 10000, 1 <= m <= 50000.

Your code should read the input from standard input (e.g.
using functions `input()/raw_input()` in Python and `cin/scanf` in C++).

# Output

One number representing the number of connected components in the graph.


Your code should write the output to standard output (e.g. using functions `print` in Python and `cout/printf` in C++).

# Requirement

Your algorithm should run in O(|V| + |E|) time.

Time limtation: 5 seconds.

Memory limitation: 1.0 GB.

# Environment

Your code will be running on Ubuntu 18.04.5.

Now only accept C++ and Python2/Python3 code, g++ version 7.5.0 and Python versions are Python 2.7.17 and Python 3.6.9.

# Examples and Testing

Some examples (e.g., input-x.txt and output-x.txt, x = 1, 2) are provided.
A figure corresponding input-1 can be found in this repo too.
For Python code, try the following to test your code
```
python ./solution.py < input-x.txt > my-output-x.txt
```
For C++ code, try the following to test your code
```
g++ -o mybinary solution.cpp
./mybinary < input-x.txt > my-output-x.txt
```

Your output `my-output-x.txt` needs to be *match exactly* to the given `output-x.txt`.
On Unix-based systems you can use `diff` to compare them:
```
diff my-output-x.txt output-x.txt
```
On Windows you can use `fc` to compare them:
```
fc my-output-x.txt output-x.txt
```

# Submission

If you want to upload a single file, make sure the file is named as `solution.py` (for Python) or `solution.cpp` (for C++).
If you submit via GitHub, make sure your file is located in directory `assignment3/problem1/solution.py` (for Python) or `assignment3/problem1/solution.cpp` (for C++).

# Hints

Use adjacency list to store all the edges.

In: Computer Science

# Compare two Xml_ file in C# and extract the difference between them in other xml_file...

# Compare two Xml_ file in C# and extract the difference between them in other xml_file

Hi!

I have problem about xml_file, I need to compare between two xml_file with deferent values and I must extract the deference in a new xml file in C#, .Net, I need to write program(not Microsoft XmlDiff and Patch tools). If you can help me please!

Thank you!

Original file is the first one!

<root>

<data name="senChangePassword" xml:space="preserve">

<value>Hi</value>

<comment> Jessica</comment>

</data>

<data name="senChangesWereSuccessfullySaved" xml:space="preserve">

<value>save change.</value>

<comment> Jessica</comment>

</data>

<data name="senChangeUserSettings" xml:space="preserve">

<value>change data</value>

<comment> Jessica</comment>

</data>

<data name="senCompareWith" xml:space="preserve">

<value>Compare</value>

<comment>Jessica</comment>

</data>

<data name="senPasswordResetMailText" xml:space="preserve">

<value>Here projectportal.&lt;br/&gt;&lt;br/&gt;[password]&lt;br/&gt;&lt;br/&gt;go to projectportal: [link]&lt;br/&gt;&lt;br/&gt;Thankyou&lt;br/&gt;&lt;/br&gt;[manager]</value>

<comment>09-2019</comment>

</data>

<data name="senCreatedQuestions" xml:space="preserve">

<value>Save</value>

<comment>Jessica</comment>

</data>

</root>

===========================================

The second xlm_file

<?xml version="1.0" encoding="UTF-8" ?>

<root>

<data name="senChangePassword" xml:space="preserve">

<value>Change Password</value>

<comment> Jessica</comment>

</data>

<data name="senChangeUserSettings" xml:space="preserve">

<value>Change data</value>

<comment>Jessica</comment>

</data>

<data name="senCompareWith" xml:space="preserve">

<value>Compare</value>

<comment> Jessica</comment>

</data>

<data name="senPasswordResetMailText" xml:space="preserve">

<value>Here you get a new password for the project portal.&lt;br/&gt;&lt;br/&gt;[password]&lt;br/&gt;&lt;br/&gt;Follow this link to the project portal: [link]&lt;br/&gt;&lt;br/&gt;Sincerely&lt;br/&gt;&lt;/br&gt;[manager]</value>

<comment> 09-2019</comment>

</data>

<data name="senCreatedQuestions" xml:space="preserve">

<value>Created questions</value>

<comment> Jessica</comment>

</data>

</root>

======================================================
 


In: Computer Science

In 2015, the Keenan Company paid dividends totaling $2,740,000 on net income of $12 million. Note...

In 2015, the Keenan Company paid dividends totaling $2,740,000 on net income of $12 million. Note that 2015 was a normal year and that for the past 10 years, earnings have grown at a constant rate of 4%. However, in 2016, earnings are expected to jump to $19.2 million and the firm expects to have profitable investment opportunities of $9.6 million. It is predicted that Keenan will not be able to maintain the 2016 level of earnings growth because the high 2016 earnings level is attributable to an exceptionally profitable new product line introduced that year. After 2016, the company will return to its previous 4% growth rate. Keenan's target capital structure is 40% debt and 60% equity.

Regular-dividend $
Extra dividend $
  1. Calculate Keenan's total dividends for 2016 assuming that it follows each of the following policies: (Write out your answers completely. For example, 25 million should be entered as 25,000,000.)
    1. Its 2016 dividend payment is set to force dividends to grow at the long-run growth rate in earnings. Round your answer to the nearest cent.
      $

    2. It continues the 2015 dividend payout ratio. Round your answer to the nearest cent. Do not round intermediate calculations.
      $

    3. It uses a pure residual dividend policy (40% of the $9.6 million investment is financed with debt and 60% with common equity). Round your answer to the nearest cent.
      $

    4. It employs a regular-dividend-plus-extras policy, with the regular dividend being based on the long-run growth rate and the extra dividend being set according to the residual dividend policy. Round your answer to the nearest cent.

  2. Which of the preceding policies would you recommend?
    -Select-Policy 1Policy 2Policy 3Policy 4Item 6

  3. Assume that investors expect Keenan to pay total dividends of $8,000,000 in 2016 and to have the dividend grow at 4% after 2016. The stock's total market value is $210 million. What is the company's cost of equity? Round your answer to two decimal places.
    %

  4. What is Keenan's long-run average return on equity? [Hint: g = Retention rate x ROE = (1.0 - Payout rate)(ROE).] Do not round intermediate calculations. Round your answer to two decimal places.
    %

  5. Does a 2016 dividend of $8,000,000 seem reasonable in view of your answers to parts c and d? If not, should the dividend be higher or lower?
    Yes or No it should be lower or No, it should be higher

In: Finance

ALTERNATIVE DIVIDEND POLICIES In 2015, the Keenan Company paid dividends totaling $2,390,000 on net income of...

ALTERNATIVE DIVIDEND POLICIES

In 2015, the Keenan Company paid dividends totaling $2,390,000 on net income of $10 million. Note that 2015 was a normal year and that for the past 10 years, earnings have grown at a constant rate of 4%. However, in 2016, earnings are expected to jump to $17 million and the firm expects to have profitable investment opportunities of $7.4 million. It is predicted that Keenan will not be able to maintain the 2016 level of earnings growth because the high 2016 earnings level is attributable to an exceptionally profitable new product line introduced that year. After 2016, the company will return to its previous 4% growth rate. Keenan's target capital structure is 40% debt and 60% equity.

Regular-dividend $
Extra dividend $
  1. Calculate Keenan's total dividends for 2016 assuming that it follows each of the following policies: (Write out your answers completely. For example, 25 million should be entered as 25,000,000.)
    1. Its 2016 dividend payment is set to force dividends to grow at the long-run growth rate in earnings. Round your answer to the nearest cent.
      $

    2. It continues the 2015 dividend payout ratio. Round your answer to the nearest cent. Do not round intermediate calculations.
      $

    3. It uses a pure residual dividend policy (40% of the $7.4 million investment is financed with debt and 60% with common equity). Round your answer to the nearest cent.
      $

    4. It employs a regular-dividend-plus-extras policy, with the regular dividend being based on the long-run growth rate and the extra dividend being set according to the residual dividend policy. Round your answer to the nearest cent.

  2. Which of the preceding policies would you recommend?
    -Select-Policy 1Policy 2Policy 3Policy 4Item 6

  3. Assume that investors expect Keenan to pay total dividends of $10,000,000 in 2016 and to have the dividend grow at 4% after 2016. The stock's total market value is $170 million. What is the company's cost of equity? Round your answer to two decimal places.
    %

  4. What is Keenan's long-run average return on equity? [Hint: g = Retention rate x ROE = (1.0 - Payout rate)(ROE).] Do not round intermediate calculations. Round your answer to two decimal places.
    %

  5. Does a 2016 dividend of $10,000,000 seem reasonable in view of your answers to parts c and d? If not, should the dividend be higher or lower?

In: Finance

Can someone find what's wrong? If I don't use the last main method Netbeans says that...

Can someone find what's wrong? If I don't use the last main method Netbeans says that there is no main method. I can't figure out what's wrong.

This was the prompt:

Design a class named triangle that extends geometricObject. For this, you should have created a GeometricObject class first. The class contains:

  • Three double datafields named side1, side2, side3 with default value 1.0.
  • A no arg constructor that creates a default triangle.
  • A constructor that creates a triangle with specified side1, side2 and side3.
  • A method named getPerimeter() that returns the perimeter of a triangle.
  • A method name toString that returns the string description of a triangle.(including color and filled)

Your main method should create a triangle object and display it using toString()

This is my code:

package geometricobject;

/**
*
*
*/
public class GeometricObject {

/**
* @param args the command line arguments
*/
private String color = "white";
private boolean filled;
private java.util.Date dateCreated;

public GeometricObject() {
dateCreated = new java.util.Date();
}

public GeometricObject(String color, boolean filled) {
dateCreated = new java.util.Date();
this.color = color;
this.filled = filled;
}

public String getColor() {
return color;
}

public void setColor(String color) {
this.color = color;
}

public boolean isFilled() {
return filled;
}

public void setFilled(boolean filled) {
this.filled = filled;
}

public java.util.Date getDatecreated() {
return dateCreated;
}
  
public String toString() {
return "created on" + dateCreated + "\ncolor: " + color+ " and filled: " + filled;
}
  


public class triangle extends GeometricObject
{
private double side1;
private double side2;
private double side3;
  
public triangle() {
side1 = 1;
side2 = 1;
side3 = 1;
}
  
public triangle(double side1, double side2, double side3) {
this.side1 = side1;
this.side2 = side2;
this.side3 = side3;
}
public double getSide1() {
return side1;
}
public double getSide2() {
return side2;
}
public double getSide3() {
return side3;
}
public void setSide1(double side1) {
this.side1 = side1;
}
public void setSide2(double side2) {
this.side2 = side2;
}
public void setSide3(double side3) {
this.side3 = side3;
}
public double getArea() {
double n = (side1+side2+side3) / 2.0;
return Math.sqrt(n*(n-side1)*(n-side2)*(n-side3));
}
public double getPerimeter() {
return side1 + side2 + side3;
}
  
@Override
public String toString() {
return super.toString() + "Triangle: side1 = " + side1 + " side2 = " + side2 + "side3 = " + side3 ;

}}}

In: Computer Science