hat does the code below do?
clear
vec = randi(20,1,100)-10;
iter=0;
k=1;
while k<= length(vec)
if vec(k)<0
vec(k)= vec(k) * -1;
end
k = k+1;
end
a.
This code generates a vector with 100 random integer elements between 20 and 100, and changes the sign of the elements coverting all poivitive ones to negative and all negative ones to positive.
b.
This code generates a vector with 20 random integer elements between 1 and 100, and changes the sign of all the elements.
c.
This code generates a vector with 20 random integer elements between -100 and 100, and replaces all the negative integers with a positive integer of the same absolute value.
d.
This code generates a vector with 100 random integer elements between -10 and 10, and changes the sign of all negative elements.
e.
This code generates a vector with 20 random integer elements between 1 and 100, and changes the sign of all negative elements.
In: Computer Science
In: Finance
Question:
Rotate and sort the list:-
In this problem, you have to first implement a singly linked list whose each node should have the following attributes,
● key - a positive integer
● next - address/pointer/reference to the next node in the linked list You will receive Q1 queries of following types,
● 1 x - Append a node to the linked list whose key should be x. After appending, print, in a new line, the key of each node in the linked list separated by a single space.
● 2 x - Delete the node in the linked list whose key is x.If such a node is not present in the linked list, no changes should be made. After this, print, in a new line, the key of each node in the linked list separated by a single space. The deleted node, if any, should be added in another linked list. Then you will receive Q2 queries of the following type,
● k - The linked list should be rotated towards right by |k| steps if k > 0, otherwise the linked list should be rotated towards left by |k| steps. k will always be an integer. Once all of the above Q2 queries are done, print, in a new line, the key of each node in the linked list separated by a single space. Then you have to merge the two linked lists together after sorting (by key), each of them using the merge sort algorithm. Once done, print in a new line, the key of each node in the linked list separated by a single space. Note that the linked list in the end should also be sorted by key.
Input Format - The first line will contain a positive integer, Q1 , following which there will be Q1 lines containing queries as described above. Then the very next line will contain a positive integer Q2 following which will be Q2 lines containing queries as described above.
Output Format - Q1 + 2 lines with space separated values of the key of each node in the linked list as explained above.
Constraints ● 0 < Q1 < 1000
● 0 < Q2 < 10000
● 0 < key, x < 1000
● -100 < k < 100
In: Computer Science
First make the changes in P82.cpp and call the new program ex82.cpp. Compile and run the program and make sure it produces the correct results. Here is what you need to do for the exercise:
Overload the % operator such that every time
you use it, it takes two objects of type AltMoney as its arguments
and returns:
a) 5% of the difference between the income and expenditure, if
income is larger than the expenditure
b) -2% if the the expenditure is larger than the income.
c) 0 if the expenditure is the same as income
Note that, by doing this, you are required to overload the
greater than sign (>), the smaller than sign (<), and the ==
sign.
#include<iostream>
#include<cstdlib>
using namespace std;
class AltMoney
{
public:
AltMoney();
AltMoney(int d, int c);
friend AltMoney operator +(AltMoney m1, AltMoney m2);
void display_money();
private:
int dollars;
int cents;
};
void read_money(int& d, int& c);
int main()
{
int d, c;
AltMoney m1, m2, sum;
sum = AltMoney(0, 0);
read_money(d, c);
m1 = AltMoney(d, c);
cout << "The first money is:";
m1.display_money();
read_money(d, c);
m2 = AltMoney(d, c);
cout << "The second money is:";
m2.display_money();
sum = m1 + m2;
cout << "The sum is:";
sum.display_money();
return 0;
}
AltMoney::AltMoney()
{
}
AltMoney::AltMoney(int d, int c)
{
dollars = d;
cents = c;
}
void AltMoney::display_money()
{
cout << "$" << dollars << ".";
if (cents <= 9)
cout << "0"; //to display a 0 on the left for numbers less than 10
cout << cents << endl;
}
AltMoney operator +(AltMoney m1, AltMoney m2)
{
AltMoney temp;
int extra = 0;
temp.cents = m1.cents + m2.cents;
if (temp.cents >= 100) {
temp.cents = temp.cents - 100;
extra = 1;
}
temp.dollars = m1.dollars + m2.dollars + extra;
return temp;
}
void read_money(int& d, int& c)
{
cout << "Enter dollar \n";
cin >> d;
cout << "Enter cents \n";
cin >> c;
if (d < 0 || c < 0)
{
cout << "Invalid dollars and cents, negative values\n";
exit(1);
}
}
In: Computer Science
Slope and the maximum height of a curve
This problem gives you a preview of something you might see in a microeconomics class. Suppose there’s an appliance store that sells air conditioners. It could set its price high and sell very few air conditioners, or it could set its price low and sell many more air conditioners. The following table shows some possible choices this store could make:

The graph below plots the firm’s total revenue curve: that is, the relationship between quantity and total revenue given by the two right columns in the table above. The five choices are also labeled. Finally, two black lines are shown; these lines are tangent to the green curve at points B and D.

Using the information on the slope of the lines tangent to the curve at points B and D, plot the slope of the total revenue curve on the graph below. (As it turns out, it’s a straight line, so the two points you plot will determine a line.)

The total revenue curve reaches its maximum at a quantity of (400, 200, 100, 300) air conditioners per year. At this point, the slope of the total revenue curve is (negative, equal to zero, positive, at its maximum, at its minimum) .
In: Economics
EPS, P/E Ratio, and Dividend Ratios
The Stockholders' Equity section of the balance sheet for Obregon, Inc. at the end of 2017 appears as follows:
| 8%, $100 par, cumulative preferred stock, 200,000 shares authorized, 50,000 shares issued and outstanding | $5,000,000 | |
| Additional paid-in capital on preferred | 2,500,000 | |
| Common stock, $5 par, 500,000 shares authorized, 400,000 shares issued and outstanding | 2,000,000 | |
| Additional paid-in capital on common | 18,000,000 | |
| Retained earnings | 37,500,000 | |
| Total stockholders' equity | $65,000,000 | |
Net income for the year was $1,345,000. Dividends were declared and paid on the preferred shares during the year, and a quarterly dividend of $0.30 per share was declared and paid each quarter on the common shares. The closing market price for the common shares on December 31, 2017, was $21.15 per share.
Required:
1. Compute the following ratios for the common stock:
When required, round earnings per share and price/earnings ratio answers to two decimal places. For dividend payout and dividend yield ratios, round raw calculations to 4 decimal places, but enter each answer as a percentage to two decimal places; for example, .17856 rounds to .1786 and would be entered as 17.86, indicating 17.86%.
| a. Earnings per share | $? | |
| b. Price/earnings ratio | ? to 1 | |
| c. Dividend payout ratio | ? % | |
| d. Dividend yield ratio | ? % |
2. Before recommending the stock of Obregon to a client, as a financial adviser, you would like to know:
d
In: Accounting
In: Economics
1. Felicia Álvarez, a bakery manager, faces the total product curve shown, which gives the relationship between the number of workers she hires each day and the number of loaves of bread she produces, assuming all other factors of production are given.
|
Number of workers per day |
Loaves of bread per day |
Marginal Product |
Marginal Revenue Product |
|
0 |
0 |
||
|
1 |
400 |
||
|
2 |
700 |
||
|
3 |
900 |
||
|
4 |
1,025 |
||
|
5 |
1,100 |
||
|
6 |
1,150 |
Assume that bakery workers in the area receive a wage of $100 per day and that the price of bread is $1.00 per loaf.
In: Economics
The following data show the brand, price ($), and the overall score for six stereo headphones that were tested by a certain magazine. The overall score is based on sound quality and effectiveness of ambient noise reduction. Scores range from 0 (lowest) to 100 (highest). The estimated regression equation for these data is
ŷ = 23.462 + 0.315x,
where x = price ($) and y = overall score.
| Brand | Price ($) | Score |
|---|---|---|
| A | 180 | 74 |
| B | 150 | 73 |
| C | 95 | 59 |
| D | 70 | 58 |
| E | 70 | 42 |
| F | 35 | 24 |
(a)
Compute SST, SSR, and SSE. (Round your answers to three decimal places.)
SST=
SSR=
SSE=
(b)
Compute the coefficient of determination r2.
(Round your answer to three decimal places.)
r2
=
Comment on the goodness of fit. (For purposes of this exercise, consider a proportion large if it is at least 0.55.)
The least squares line provided a good fit as a small proportion of the variability in y has been explained by the least squares line.
The least squares line provided a good fit as a large proportion of the variability in y has been explained by the least squares line.
The least squares line did not provide a good fit as a large proportion of the variability in y has been explained by the least squares line.
The least squares line did not provide a good fit as a small proportion of the variability in y has been explained by the least squares line.
(c)
What is the value of the sample correlation coefficient? (Round your answer to three decimal places.)
In: Statistics and Probability
1. In 1995, the Food and Drug Administration (FDA) published new labeling standards for bottled water. (The full text of the final rule can be found at http://cfr.vlex.com/vid/165-110-bottled-water-19705533.) Prior to that time, bottlers could sell regular tap water under a bottled water label. In fact, the FDA estimated that approximately 25 percent of the supply of bottled water was nothing more than ordinary tap water.
(a) Consider how these tougher standards eliminated 25 percent of the supply of bottled water. If market demand is unaffected, what qualitative impact would this labeling change have on equilibrium price and quantity for bottled water? Support your answer with a graphical model.
(b) Let the market demand and market supply equations are QD = −100P+ 1, 150 and QS = 400P − 100. How much of bottled water would be supplied in a static efficient allocation and at what price?
Now, suppose the change in standards results in a new market supply of QS new = 400P − 350 with no change in market demand.
(c) Determine the new static efficient allocation for bottled water and new market price. Do your results agree with your intuitive answer to part (a)? (d) Graphically illustrate the market for bottled water before and after the change in labeling standards. Be sure to label all relevant points.
(e) Compare the values of consumer surplus and producer surplus before and after the change in labeling standards. Is this result expected? Why or why not?
In: Economics