C++
For this assignment, you will implement the MyString class. Like the string class in C++’s standard library, this class uses C-strings as the underlying data structure. Recall that a C-string is a null-terminated array of type char. See section 8.1 in Savitch for more information about C-strings; in particular, you will find it helpful to take advantage of several of the C-string functions mentioned in that section. What To Do. In the hw8 directory that is created, you will find the following files: • mystring.h and mystring.cpp • a Makefile • and 4 test files (test1.cpp through test4.cpp). (Below are the files mentioned here, with one sample file). Implement the following: 1. a default constructor 2. a constructor that takes a const char * parameter (that is, a C-string) 3. a destructor 4. a copy constructor 5. the assignment operator. In addition, overload the following relational operators: >, <, >=, <=, ==, and !=. Lastly, overload the operator+ (concatenation). All of the relational operators return type int. To understand why, read the description of the C-string function strcmp. All of the comparisons should be lexicographical, i.e., similar to what strcmp() does. The == and != operators should evaluate to 1 if the condition is true, 0 if false. You are welcome to implement some of the operators by using others (for example, you can easily implement != using ==). Make sure that you can invoke the operators with string literals on either side of the operator. That is, both of the following expressions should be valid: str == "hello" "hello" == str where str is a MyString object. Place the member function implementations in mystring.cpp and compile using make. You can also edit mystring.h if you wish to implement some of the member functions directly in the class definition
Make File:
CC = g++
CXX = g++
INCLUDES =
CFLAGS = -Wall $(INCLUDES)
CXXFLAGS = -Wall $(INCLUDES)
LDFLAGS =
LDLIBS =
executables = test1 test2 test3 test4
objects = mystring.o test1.o test2.o test3.o test4.o
.PHONY: default
default: $(executables)
$(executables): mystring.o
$(objects): mystring.h
.PHONY: clean
clean:
rm -f *~ a.out core $(objects) $(executables)
.PHONY: all
all: clean default
mystring.cpp:
#include
#include
#include "mystring.h"
// Insertion (put-to) operator
std::ostream& operator<<(std::ostream& outs, const MyString& s)
{
outs << s.data;
return outs;
}
// Extraction (get-from) operator
std::istream& operator>>(std::istream& is, MyString& s)
{
// Though this cheats a bit, it's meant to illustrate how this
// function can work.
std::string temp;
is >> temp;
delete[] s.data;
s.len = strlen(temp.c_str());
s.data = new char[s.len+1];
strcpy(s.data, temp.c_str());
return is;
}
mystring.h:
#ifndef _MYSTRING_H_
#define _MYSTRING_H_
#include
class MyString {
public:
// default constructor
MyString();
// constructor
MyString(const char* p);
// destructor
~MyString();
// copy constructor
MyString(const MyString& s);
// assignment operator
MyString& operator=(const MyString& s);
// returns the length of the string
int length() const { return len; }
// insertion (or put-to) operator
friend std::ostream& operator<<(std::ostream& outs, const MyString& s);
// extraction (or get-from) operator
friend std::istream& operator>>(std::istream& is, MyString& s);
// concatenates two strings
friend MyString operator+(const MyString& s1, const MyString& s2);
// relational operators
friend int operator<(const MyString& s1, const MyString& s2);
friend int operator>(const MyString& s1, const MyString& s2);
friend int operator==(const MyString& s1, const MyString& s2);
friend int operator!=(const MyString& s1, const MyString& s2);
friend int operator<=(const MyString& s1, const MyString& s2);
friend int operator>=(const MyString& s1, const MyString& s2);
private:
char* data;
int len;
};
#endif
Here is a sample test file:
#include "mystring.h"
static MyString add(MyString s1, MyString s2)
{
MyString temp(" and ");
return s1 + temp + s2;
}
int main()
{
using namespace std;
MyString s1("one");
MyString s2("two");
MyString s3 = add(s1, s2);
cout << s3 << endl;
return 0;
}
In: Computer Science
Explain two factors that may affect the IT project cost estimation using your own words. Support your answer with examples.
In: Computer Science
True/False: The advantage to being the late mover or follower strategy is that you learn from the mistakes that the first mover makes.
True/False: Firms have to choose between two different strategies of entry one is a non-equity strategy and the other is an equity strategy.
True/False:Joint ventures are considered a desirable strategy for firms that want tight control over the foreign operations.
Please also give a reasoning if you can, thanks!
In: Operations Management
The Neal Company wants to estimate next year's return on equity (ROE) under different financial leverage ratios. Neal's total capital is $14 million, it currently uses only common equity, it has no future plans to use preferred stock in its capital structure, and its federal-plus-state tax rate is 40%. The CFO has estimated next year's EBIT for three possible states of the world: $5.8 million with a 0.2 probability, $3.4 million with a 0.5 probability, and $0.6 million with a 0.3 probability. Calculate Neal's expected ROE, standard deviation, and coefficient of variation for each of the following debt-to-capital ratios. Do not round intermediate calculations. Round your answers to two decimal places at the end of the calculations.
Debt/Capital ratio is 0.
RÔE = | % |
σ = | % |
CV = |
Debt/Capital ratio is 10%, interest rate is 9%.
RÔE = | % |
σ = | % |
CV = |
Debt/Capital ratio is 50%, interest rate is 11%.
RÔE = | % |
σ = | % |
CV = |
Debt/Capital ratio is 60%, interest rate is 14%.
RÔE = | % |
σ = | % |
CV = |
In: Finance
A set of X-Y data pairs are
X | Y |
-0.14 | 0.69 |
1.91 | -0.25 |
2.33 | 2.29 |
3.68 | 3.72 |
3.51 | 3.23 |
4.09 | 4.76 |
6.27 | 7.88 |
6.32 | 8.59 |
7.42 | 8.73 |
8.72 | 8.45 |
10.35 | 10.67 |
10.09 | 11.29 |
Compute the intercept β0 regression coefficient for this data.
In: Math
Why should a Code of Ethics be established and supported by senior leadership in a healthcare facility? 250 words please.
In: Nursing
Please Use your keyboard (Don't use handwriting)
MGT211
I need new and unique answers, please. (Use your own words, don't copy and paste)
THE RELUCTANT WORKERS
Tim Aston had changed employers three months ago. His new position was project manager.
At first he had stars in his eyes about becoming the best project manager that his company had ever seen. Now, he wasn’t sure if project management was worth the effort. He made an appointment to see Phil Davies, director of project management.
Tim Aston: “Phil, I’m a little unhappy about the way things are going. I just can’t seem to motivate my people. Every day, at 4:30 P.M., all of my people clean off their desks and go home. I’ve had people walk out of late afternoon team meetings because they were afraid that they’d miss their car pool. I have to schedule morning team meetings.”
Phil Davies: “Look, Tim. You’re going to have to realize that in a project environment, people think that they come first and that the project is second. This is a way of life in our organizational form.”
Tim Aston: “I’ve continually asked my people to come to me if they have problems. I find that the people do not think that they need help and, therefore, do not want it. I just can’t get my people to communicate more.”
Phil Davies: “The average age of our employees is about forty-six. Most of our people have been here for twenty years. They’re set in their ways. You’re the first person that we’ve hired in the past three years. Some of our people may just resent seeing a thirty-year-old project manager.”
Tim Aston: “I found one guy in the accounting department who has an excellent head on his shoulders. He’s very interested in project management. I asked his boss if he’d release him for a position in project management, and his boss just laughed at me, saying something to the effect that as long as that guy is doing a good job for him, he’ll never be released for an assignment elsewhere in the company. His boss seems more worried about his personal empire than he does in what’s best for the company.
“We had a test scheduled for last week. The customer’s top management was planning on flying in for firsthand observations. Two of my people said that they had programmed vacation days coming, and that they would not change, under any conditions. One guy was going fishing and the other guy was planning to spend a few days working with fatherless children in our community. Surely, these guys could change their plans for the test.”
Phil Davies: “Many of our people have social responsibilities and outside interests. We encourage social responsibilities and only hope that the outside interests do not interfere with their jobs.
“There’s one thing you should understand about our people. With an average age of fortysix, many of our people are at the top of their pay grades and have no place to go. They must look elsewhere for interests. These are the people you have to work with and motivate. Perhaps you should do some reading on human behavior.
In: Operations Management
PLEASE I HAVE TO RETURN IN 20 MINUTES, I HAVE ALREADY DO THE QUESTION 1, 2, 3, 4 BUT THE QUESTION 5 I CAN'T
In python :
1)Write a sum function expecting an array of integers and returning its sum.
2) Write a multiply function excepting two arrays of integers and returning the product array term by term.
For example mutliply([1,2,3], [5,4,3]) will give [5,8,9]
3) Write a nb1 function expecting an array containing only 0 and 1 and returning the number of 1 present in the array.
4)Write a conFilter function expecting an integer n and creating an array of size n randomly filled with 0 and 1.
5) With these functions offer a random solution to the backpack problem. Here are some indications:
- The consFilter function allows you to construct an array retaining only one part of the objects to place in your backpack. So if the list of objects is [1,4,6,1] and the filter is [1,0,1,0], then by doing the product of the two you will get [1,0,6,0].
- You can generate a large number of random filters, for each of these filters to test if the objects thus filtered fit in the backpack. The rest comes down to a maximum calculation.
- You must make the best list of the weights of the objects fitting in the backpack. For example, if your backpack can hold 20kg, the list of items is [10, 1, 5, 8, 3, 9], one of the ways to optimize your bag is to put [10, 1, 3, 5] or 19kg.
Test on tables of 10-15 objects between 1 and 100kg each for a bag weight of 200 to 300kg.
In: Computer Science
You own a small networking startup. You have just received an offer to buy your firm from a large, publicly traded firm, JCH Systems. Under the terms of the offer, you will receive 1 million shares of JCH. JCH stock currently trades for $25.63 per share. You can sell the shares of JCH that you will receive in the market at any time. But as part of the offer, JCH also agrees that at the end of one year, it will buy the shares back from you for $25.63 per share if you desire. Suppose the current one-year risk-free rate is 5.95%, the volatility of JCH stock is 29.4%, and JCH does not pay dividends. Round all intermediate values to five decimal places as needed.
a. Is this offer worth more than $25.63 million? Explain.
b. What is the value of the offer?
In: Finance
Critique the stage model by identifying at least two strengths and potential weaknesses of using this framework for understanding family process.
In: Psychology
A 15-year bond issue of 5,100,000 and bearing interest at 4% payable annually is sold to yield 4.4% compounded semi-annually. What is the issue price of the bonds?
In: Finance
On December 31, 2017, Vernon Vacations Inc. reported the following shareholders’ equity:
issued and outstanding, dividends have been paid up to date $ 400,000
outstanding 1,000,000
total: $3,000,000
During 2018, the company reported the following transactions and events:
Required:
In: Accounting
In: Biology
Example: Consider a signal sampled at 1.2 kHz which is
composed of 50HZ, 90HZ and 150HZ of sine waves, having amplitudes
of 5V, 3V and 2V respectively .
Write a MATLAB program to plot signal in time domain as well as in
frequency domain to get information about major frequency
components present in the signal.
In: Computer Science
In what ways did slavery and the Atlantic system impact African society? How did Africans respond to European intrusion and the slave trade?
In: Psychology