C++ programming
You are to implement a MyString class which is our own limited implementation of the std:: string
Header file and test (main) file are given in below, code for mystring.cpp.
Here is header file
mystring.h
/* MyString class */
#ifndef MyString_H
#define MyString_H
#include <iostream>
using namespace std;
class MyString {
private:
char* str;
int len;
public:
MyString();
MyString(const char* s);
MyString(MyString& s);
~MyString();
friend ostream& operator <<(ostream& os, MyString& s); // Prints string
MyString& operator=(MyString& s); //Copy assignment
MyString& operator+(MyString& s); // Creates a new string by concantenating input string
};
#endif
Here is main file, the test file
testMyString.cpp
/* Test for MyString class */
#include <iostream>
#include "mystring.h"
using namespace std;
int main()
{
char greeting[] = "Hello World!";
MyString str1(greeting); // Tests constructor
cout << str1 << endl; // Tests << operator. Should print Hello World!
char bye[] = "Goodbye World!";
MyString str2(bye);
cout << str2 << endl; // Should print Goodbye World!
MyString str3{str2}; // Tests copy constructor
cout << str3 << endl; // Should print Hello World!
str3 = str1; // Tests copy assignment operator
cout << str3 << endl; // Should print Goodbye World!
str3 = str1 + str2; // Tests + operator
cout << str3 << endl; // Should print Hello World!Goodbye World!
return 0;
}
In: Computer Science
A charge of -2.75 nC is placed at the origin of an xy-coordinate system, and a charge of 2.05 nC is placed on the y axis at y = 3.60 cm .
A. If a third charge, of 5.00 nC , is now placed at the point x = 2.65 cm , y = 3.60 cm find the x and y components of the total force exerted on this charge by the other two charges.
B. Find the magnitude of this force.
C. Find the direction of this force.
In: Physics
In: Nursing
|
NEW PROJECT ANALYSIS You must evaluate a proposal to buy a new milling machine. The base price is $195,000, and shipping and installation costs would add another $13,000. The machine falls into the MACRS 3-year class, and it would be sold after 3 years for $87,750. The applicable depreciation rates are 33%, 45%, 15%, and 7%. The machine would require a $6,000 increase in net operating working capital (increased inventory less increased accounts payable). There would be no effect on revenues, but pretax labor costs would decline by $50,000 per year. The marginal tax rate is 35%, and the WACC is 10%. Also, the firm spent $5,000 last year investigating the feasibility of using the machine. How should the $5,000 spent last year be handled? A. Last year's expenditure is considered as a sunk cost and does not represent an incremental cash flow. Hence, it should not be included in the analysis. B. The cost of research is an incremental cash flow and should be included in the analysis. C. Only the tax effect of the research expenses should be included in the analysis. D. Last year's expenditure should be treated as a terminal cash flow and dealt with at the end of the project's life. Hence, it should not be included in the initial investment outlay. E. Last year's expenditure is considered as an opportunity cost and does not represent an incremental cash flow. Hence, it should not be included in the analysis. What is the initial investment outlay for the machine for
capital budgeting purposes, that is, what is the Year 0 project
cash flow? Round your answer to the nearest cent. What are the project's annual cash flows during Years 1, 2, and 3? Round your answer to the nearest cent. Do not round your intermediate calculations. Year 1 $ Year 2 $ Year 3 $ Should the machine be purchased? |
In: Finance
1) Two vectors, r and s lie in the x y plane. Their magnitudes are 4.84 and 6.09 units respectively, and their directions are 341o and 65.0o respectively, as measured counterclockwise from the positive x axis. What are the values of vectors (a) r . s and (b) | r × s |?
2) For the following three vectors A B C, what is 3⋅C . (3A × B)
?
A =3.00î + 2.00ĵ - 3.00k̂
B =-4.00î + 3.00ĵ + 3.00k̂
C =6.00î - 7.00ĵ
In: Physics
In: Operations Management
1) 10000 lb/h of a 40.00% NaoH solution is crystallized through a combined evaporator-crystallizer process. The feed enters an evaporator which concentrates it to 50.00% NaOH. The concentrated solution then enters the crystallizer with a built in filter. The crystal product is 95% NaOH crystals with the remaining 5% as adhering mother liquor solution. The mother liquor, containing 45.00% NaOH, is mixed back to the feed before entering the evaporator. Determine the recycle flow rate.
2) Resolve the problem, now considering if the mother liquor is not recycled, but the entire process still generates the same amount of product (crystals) as the original problem. Retain all concentrations given. Determine the amount of feed needed if the recycle stream was removed. Compare the recovery ratio (lb NaOH recovered as crystals/lb NaOH in feed) for the two cases to see the importance of the recycle stream.
In: Other
STRICT DOWNVOTE IF NOT DONE FULLY, WILL REPORT ALSO IF COPY PASTED OR MODIFIED ANSWER Develop a class, using templates, to provide functionality for a set of recursive functions. The functions specified as recursive must be written recursively (not iterativly). The UML class specifications are provided below. A main will be provided. Additionally, a make file will need to be developed and submitted. ● Recursion Set Class The recursion set template class will implement the template functions. recursionSet -length: int -*mySet: myType -MAX_VALUE = 500000 static const: int -LIMIT = 1000 static const: int +recursionSet() +recursionSet(const recursionSet&) +~recursionSet() +getSetLength() const: int +generateElements(int): void + getElement(int) const: myType +setElement(int, myType): void +readValue(const string) const: int +printSet() const: void +operator == (const recusrionSet&): bool +tak(myType, myType, myType) const: myType +printSeptenary(myType) const: void +squareRoot(myType, myType) const: myType -recSqRoot(myType, myType, myType) const: myType +recursiveSum() const: myType -rSum(int) const: myType +checkParentheses(string) const: bool -recChkPar(string, int, int) const: bool +recursiveInsertionSort(): void -recInsSort(int, int): void -insertInOrder(myType, int, int): voidYou may add additional private functions if needed (but, not for the recursive functions). Note, points will be deducted for especially poor style or inefficient coding. Function Descriptions • The recursionSet() constructor should set the length to 0 and mySet pointer to NULL. • The recusrsionSet(const recursionBucket&) copy constructor should create a new, deep copy from the passed object. • The ~recursionSet() destructor should delete the myType array, set the pointer to NULL, and set the size to 0. • The setElement(int, myValue) function should set an element in the class array at the given index location (over-writing any previous value). The function must include bounds checking. If an illegal index is provided, a error message should be displayed. • The getElement(int) should get and return an element from the passed index. This must include bounds checking. If an illegal index is provided, a error message should be displayed and a 0 returned. • The getSetLength() functions should return the current class array length. • The printSet(int) function should print the formatted class array with the passed number of values per line. Use the following output statement: cout << setw(5) << mySet[i] << " • "; Refer to the sample executions for formatting example. The readValue(string) function should prompt with the passed string and read a number from the user. The function should ensure that the value is 3 1 and £ MAX_VALUE. The function should handle invalid input (via a try/catch block). If an error occurs (out of range or invalid input) an appropriate message should be displayed and the user re- prompted. Example error messages include: cout << "readSetLenth: Sorry, too many " << "errors." << endl; cout << "readSetLenth: Error, value " << cnt << " not between 1 and " << numMax << "." << endl; • Note, three errors is acceptable, but a fourth error should end the function and return 0. The generateList(int) function should dynamically create the array and use the following casting for rand() to fill the array with random values. mySet[i] = static_cast(rand()%LIMIT); • • • The printSeptenary(myType) function should print the passed numeric argument in Septenary (base-7) format. Note, function must be written recursively. The recursiveSum() function will perform a recursive summation of the values in class data set and return the final sum. The function will call the private rSum(int) function (which is recursive). The rSum(int) function accepts the length of the data set and performs a recursive summation. The recursive summation is performed as follows: rSum ( position )= • { array[ 0] array[ position ] + rSum ( position−1) if position = 0 if position > 0 The tak(myType) function should recursively compute the Tak 1 function. The Tak function is defined as follows: tak ( x , y , z) = { z tak ( tak ( x−1, y , z) , tak ( y−1, z , x) , tak ( z −1, x , y ) ) 1 For more information, refer to: http://en.wikipedia.org/wiki/Tak_(function) if y≥ x if y < x• • The squareRoot(myType, myType) function will perform a recursive estimation of the square root of the passed value (first parameter) to the passed tolerance (second parameter). The function will call the private sqRoot(myType,myType,myType) function (which is recursive). The private recSqRoot(myType,myType,myType) function recursively determines an estimated square root. Assuming initially that a = x, the square root estimate can be determined as follows: recSqRoot ( x , a , epsilon) = • • • • • { 2 if ∣ a − x ∣ ≤ epsilon a 2 (a + x) sqRoot x , , epsilon 2 a ( ) if ∣ a 2 − x ∣ > epsilon The recursiveInsertionSort() function should sort the data set array using a recursive insertion sort. The recursiveInsertionSort() function should verify the length is valid and, if so, call the recInsSort() function to perform the recursive sorting (with the first element at 0 and the last element at length-1). The recInsSort(int, int) function should implement the recursive insertion sort. The arguments are the index of the first element and the index of the last element. If the first index is less than that last index, the recursive insertion sort algorithm is follows: ▪ Recursively sort all but the last element (i.e., last-1) ▪ Insert the last element in sorted order from first through last positions To support the insertion of the last element, the insertInOrder() function should be used. The insertInOrder(myType, int, int) function should recursively insert the passed element into the correction position. The arguments are the element, the starting index and the ending index (in that order). The function has 3 operations: ▪ If the element is greater than or equal to the last element in the sorted list (i.e., from first to last). If so, insert the element at the end of the sorted (i.e, mySet[last+1] = element). ▪ If the first is less than the last, insert the last element (i.e., mySet[last]) at the end of the sorted (i.e., mySet[last+1] = mySet[last]) and continue the insertion by recursively calling the insertInOrder() function with the element, first, and last-1 values. ▪ Otherwise, insert the last element (i.e., mySet[last]) at the end of the sorted (i.e., mySet[last+1] = mySet[last]) and set the last value (i.e., mySet[last]) to the passed element. The checkParentheses(string) function should determine if the parentheses in a passed string are correctly balanced. The function should call the private recChkPar(string, int, int) function (which is recursive) The recChkPar(string, int, int) function should determine if the parentheses in a string are correctly balanced. The arguments are the string, an index (initially 0), and a parenthesis level count (initially 0). The index is used to track the current character in the string. The general approach should be as follows: ◦ Identify base case or cases. ◦ Check the current character (i.e., index) for the following use cases: ▪ if str[index] == '(' → what to do then ▪ if str[index] == ')' → what to do then ▪ if str[index] == any other character → what to do then Note, for each case, increment the index and call function recursively.
In: Computer Science
In: Biology
YOU are the financial officer at an Austrian company that wants to BUY USD 1.000.000 of solar equipment from a U.S. producer. You need to pay for the equipment in 90 days.
You have the following information available:
Spot rate $1.125 / € 90-Day forward rate $1.09 (actual spot rate expected based on historical distribution: $1.05 - $1.12)
Interest rates: US $ 4% EUR 2%
FX options available:
Contract size $125.000
CALLS : June (3 months ahead), strike price $1.10/€, Premium € 2000 per contract
PUTS : June (3 months ahead), strike price $1.00/€
Premium €1000 per contract
Futures contracts available:
Contract size $250.000
June contract, FX rate $1.11
Margin to maintain 10%
Describe your foreign exchange exposure
Describe how you would use the following instruments to hedge, i.e. how would each instrument work? (more important to describe than to calculate): Forward Contract , Options Contract
Would you recommend that the company hedge this transaction? Which instrument (any of the instruments, not just the two above) would you recommend?
In: Finance
Please read the whole program (all the way to the bottom), Thanks in advance!
Develop car rental application may use to produce a receipt. A receipt will be formatted as follows:
E Z – R I
D E R
Rental Receipt
Customer : John
Jones
Driver License : PA 12343
Telephone : 724-555-8345
Credit Card : VISA 12345678012
Vehicle : Mercedes
350E
Tag # : PA
342399
Rent Class : Luxury Sedan
Daily Rate : $ 95.00
Weekly Rate : $ 545.00
Date/Time Out : 01/10/2017 at 10:45
Date/Time In : 01/20/2017 at 11:44
Rental Charge : $ 830.00
Airport Tax : $ 150.00
Sales Tax : $ 49.80
Total : $
1029.80
For this application create four main classes for customer, rental
class, vehicle, and rental agreement. The customer class should
have six pieces of information (i.e. instance variables) including
customer name (as a String), driver’s license state (as a String),
driver’s license number (as an int), telephone number (as a
String), credit card type (as a String), and credit card number (as
a long). A rental class represents the rental terms for a class of
vehicle. For example Compact, Mid-Size, Full Size, Sport etc. are
classifications of cars with each time having different rental
terms. A rental class should have three pieces of information: a
rental class name (as a String), a daily rate (as a double) and a
weekly rate (as a double). A vehicle should have four pieces of
information: a make/model (as a String), state issuing a tag (as a
String), a tag number (as a String) and a rental class (as a rental
class). Lastly a rental agreement is the agreement of a customer to
rental a given vehicle together with the rental terms, date/time
out and date/time in. Thus a rental agreement has 4 pieces of
information: the customer, the vehicle, date/time out (as a
LocalDateTime) and date/time in.
For your customer class, provide a constructor accepting values for all instance variables. Provide getter methods for all instance variables except account number, but setter methods for only the telephone, credit card type and credit card number variables.
For rental class class, provide a constructor accepting values for all instance variable. Provide getter methods for all instance variables. Likewise for the vehicle class.
For your rental agreement class provide a constructor accepting values for all instance variables except date/time in as it is intended that this field will be given a value only when the customer returns the vehicle. Provide only getter methods for all instance variables. Provide a setter method for only the date/time in variable.
To represent a date/time use Java’s LocalDateTime class. For this class, however, do not use new to create instances. Instead use the of method:
LocalDateTime dateTimeOut = LocalDateTime.of(2017,1,10, 8, 45);
The above example creates a LocalDateTime for 1/10/2017 at 8:45.
In the rental agreement provide getRentalCharge(), getAirportTax(), getSalesTax() and getTotal() methods. The getRentalCharge() is to return the number of days rented times the daily rental rate. The getAirportTax() is to return the number of days rented times $ 15.00. The getTax() is to return the rental change times 6%. The getTotal() is to return the sum of rental charge, airport tax, and tax.
In addition to the special get methods, provide a print receipt method that will print the receipt according to the above format.
A day is a 24 hours period. However, there is a one hour grace in returning a car. That is if a car is returned after 24 hours and 59 minutes, then only one day is used in the computations. To compute the number of days between dateTimeOut and dateTimeIn, use the following code:
int noDays = Duration.between(dateTimeOut,dateTimeIn).plusMinutes(23 * 60);
BONUS 5 points: have the computation of rental charge use weekly
rate to the best benefit of the customer. The data in the example
is using the weekly rate. That is one week charge plus three days
at the daily rate. The weekly rate should be used where
it benefits the customer even in cases where it is better than the
daily rate. For example if in the example the vehicle was rented 6
days and 1 week rental charges should be used.
In addition, develop another class to test your classes by printing
three separate, and different, recepts. This class will have a main
method. In the main method, create instances of your
classes in order to print the three separate receipts. Thus, you
will hard code inside the main the values to be used when
instantiating your classes. With the exception of the fixed values
given in the computations above (for example .06 for sales tax
rate), do not hard code any other data within your classes. For
each receipt instance, call the print method to print the receipt.
Make sure to call setDateTimeIn appropriately after creating an
instance of a rental receipt and before printing.
NOTE: You do not need, and therefore should not, code any routines to input the values from the user or from files. Your test class is sufficient to demonstrate that your classes are working correctly. If you do the bonus, make sure to have data that will test the logic.
Make sure the instance variables are private. Provide javadoc for each class and methods. Abide by good programming practices.
In: Computer Science
A)Consider the following gases, all at STP: Ne, SF6, N2, CH4.
Which gas is most likely to depart from assumption 3 of the kinetic molecular theory (Attractive and repulsive forces between gas molecules are negligible.)?
Which one is closest to an ideal gas in its behavior?
Which one has the highest root-mean-square molecular speed?
Which one has the highest total molecular volume relative to the space occupied by the gas?
Which has the highest average kinetic molecular energy?
Which one would effuse more rapidly than N2?
B) A mixture of gases contains 0.75mol N2, 0.35mol O2, and 0.20mol CO2. The total pressure of the mixture is 1.57atm .
What is the partial pressure of O2?
What is the partial pressure of CO2?
C) What is the partial pressure in atm of O2 of this mixture if it is held in a 12.60?L vessel at 14?C? (O2 =.149mole)
What is the partial pressure in atm of N2 of this mixture if it is held in a 12.60?L vessel at 14?C? (N2= .241mole)
What is the partial pressure in atm of H2 of this mixture if it is held in a 12.60?L vessel at 14?C?(H2= .610mole)
In: Chemistry
Coors and Anheuser-Busch (Budweiser) are competing against each other to try to capture a larger share of the US beer market by conducting national advertising campaigns. The NFL offers the best target market audience (males, aged 18-34) because young men are the largest customer group for these companies beer products.
Each company had two advertising choices:
1. Advertise $100M annually for each company with the NFL. This would lead to profits for each company of $2B annually; or
2. Advertise $200M annually for each company with the NFL. This would lead to profits for each company of $1B annually.
However, if one company advertised $200M, while the other remained at $100M, the beer company that increased its advertising would have profits of $2.5B while the other company would have profits of $500M.
What profit outcomes will occur for Coors and Anheuser-Busch given the above framework? What is the impact on the NFL? Assume the management teams of Coors and Anheuser-Busch Make have complete knowledge (i.e. perfect information) on all of the possible outcomes, not only for their own company, but for their competitor. Make sure to draw a payoff matrix to support your answer.
In: Economics
a) How much heat is required to change a 31.3 g ice cube from ice at -10.6°C to water at 47°C? (if necessary, use cice=2090 J/kg°C and csteam= 2010 J/kg°C) b)How much heat is required to change a 31.3 g ice cube from ice at -10.6°C to steam at 110°C?
In: Physics
Two hockey pucks are moving to the right with puck 1 behind puck 2. Puck 1 is moving twice as fast as puck 2, but its mass is half that of puck 2. If puck 2's Vi is 8 m/s, then what is the velocity of each puck after they collide?
In: Physics