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 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%
In: Finance
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
In: Finance
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: Computer Science
In: Computer Science
In: Computer Science
# 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.<br/><br/>[password]<br/><br/>go to projectportal: [link]<br/><br/>Thankyou<br/></br>[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.<br/><br/>[password]<br/><br/>Follow this link to the project portal: [link]<br/><br/>Sincerely<br/></br>[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 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 | $ |
In: Finance
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 | $ |
In: Finance
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:
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