You are given a source file in your work area for this assignment.
It consists of a declaration for a Val node. There are declarations for three overloaded operator functions, which you must fill in: operator+, operator*, and operator!.
operator+ should implement addition. operator* should implement multiplication.
operator! should reverse the digits of its operand (i.e., of "this") and return the reversed integer. So for example !123 should return 321.
It should be straightforward to reverse an integer. You can extract the least significant digit by using % 10. You can remove the least significant digit by dividing by 10. Other approaches are possible as well.
These operator functions should not be a lot of code. The addition and multiplication can be written in 1-2 lines, and the reverse function within about 10 lines.
***************************************************************************************************************
THIS IS THE GIVEN PROGRAM WHICH I HAVE TO FILL IN.
********************************************************************************************************************
#include <iostream>
using namespace std;
class Val {
int v;
public:
Val(int v=0) : v(v) {}
friend ostream& operator<<(ostream&
out, const Val& v) {
out << v.v;
return out;
}
Val operator+(const Val& o) const {
// FILL IN
}
Val operator*(const Val& o) const {
// FILL IN
}
Val operator!() const {
// FILL IN
}
};
int main()
{
Val values[] = { 2, 44, 19, 4391 };
const int nv = sizeof(values)/sizeof(values[0]);
for( int i=0; i<nv; i++ ) {
cout << values[i] <<
endl;
cout << "!" <<
values[i] << " == " << !values[i] << endl;
for( int j = i+1; j < nv; j++
) {
cout <<
values[j] << endl;
cout <<
values[i] << " + " << values[j] << " == "
<< values[i] + values[j] <<
endl;
cout <<
values[i] << " * " << values[j] << " == "
<< values[i] * values[j] <<
endl;
}
}
return 0;
}
In: Computer Science
In: Accounting
Question 5
Monty Corp.’s balance sheet at December 31, 2016, is presented
below.
MONTY CORP.
Balance Sheet
December 31, 2016
Cash
$33,500
Accounts payable
$13,800
Inventory
30,050
Interest payable
2,425
Prepaid insurance
5,600
Bonds payable
48,500
Equipment
39,000
Common stock
25,400
Retained earnings
$18,025
$108,150 $108,150
During 2017, the following transactions occurred. Monty uses a
perpetual inventory system.
1. Monty paid $2,425 interest on the bonds on January 1,
2017.
2. Monty purchased $244,300 of inventory on account.
3. Monty sold for $486,000 cash inventory which cost $268,000.
Monty also collected $29,160 sales taxes.
4. Monty paid $238,000 on accounts payable.
5. Monty paid $2,425 interest on the bonds on July 1, 2017.
6. The prepaid insurance ($5,600) expired on July 31.
7. On August 1, Monty paid $10,080 for insurance coverage from
August 1, 2017, through July 31, 2018.
8. Monty paid $17,000 sales taxes to the state.
9. Paid other operating expenses, $88,000.
10. Redeemed the bonds on December 31, 2017, by paying $46,600 plus
$2,425 interest.
11. Issued $87,000 of 8% bonds on December 31, 2017, at 103. The
bonds pay interest every June 30 and December 31.
Adjustment data:
12. Recorded the insurance expired from item 7.
13. The equipment was acquired on December 31, 2016, and will be
depreciated on a straight-line basis over 5 years with a $2,800
salvage value.
14. The income tax rate is 30%. (Hint: Prepare the income statement
up to income before taxes and multiply by 30% to compute the
amount.)
Prepare an income statement for the year ending December 31,
2017.
MONTY CORP.
Income Statement
choose the accounting period
For the Year Ending December 31, 2017
For the Month Ending December 31, 2017
December 31, 2017
select a name for section one
Dividends
Gross Profit
Income From Operations
Income Before Income Taxes
Net Income / (Loss)
Net Sales
Operating Expenses
Other Revenues and Expenses
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Sales Revenues
Total Operating Expenses
Total Revenues
$enter a dollar amount
enter an income statement item
enter a dollar amount
select a summarizing line for the first part
Dividends
Gross Profit
Income From Operations
Income Before Income Taxes
Net Income / (Loss)
Net Sales
Operating Expenses
Other Revenues and Expenses
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Sales Revenues
Total Operating Expenses
Total Revenues
enter a total amount for the first part
select an opening name for section two
Dividends
Gross Profit
Income From Operations
Income Before Income Taxes
Net Income / (Loss)
Net Sales
Operating Expenses
Other Revenues and Expenses
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Sales Revenues
Total Operating Expenses
Total Revenues
enter an income statement item
$enter a dollar amount
enter an income statement item
enter a dollar amount
enter an income statement item
enter a dollar amount
select a closing name for section two
Dividends
Gross Profit
Income From Operations
Income Before Income Taxes
Net Income / (Loss)
Net Sales
Operating Expenses
Other Revenues and Expenses
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Sales Revenues
Total Operating Expenses
Total Revenues
enter a total amount for section two
select a summarizing line for the second part
Dividends
Gross Profit
Income From Operations
Income Before Income Taxes
Net Income / (Loss)
Net Sales
Operating Expenses
Other Revenues and Expenses
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Sales Revenues
Total Operating Expenses
Total Revenues
enter a total amount for the second part
select an opening name for section three
Dividends
Gross Profit
Income From Operations
Income Before Income Taxes
Net Income / (Loss)
Net Sales
Operating Expenses
Other Revenues and Expenses
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Sales Revenues
Total Operating Expenses
Total Revenues
enter an income statement item
enter a dollar amount
enter an income statement item
enter a dollar amount
select a summarizing line for the third part
Dividends
Gross Profit
Income From Operations
Income Before Income Taxes
Net Income / (Loss)
Net Sales
Operating Expenses
Other Revenues and Expenses
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Sales Revenues
Total Operating Expenses
Total Revenues
enter a total amount for the third part
enter an income statement item
enter a dollar amount
select a closing name for this statement
Dividends
Gross Profit
Income From Operations
Income Before Income Taxes
Net Income / (Loss)
Net Sales
Operating Expenses
Other Revenues and Expenses
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Sales Revenues
Total Operating Expenses
Total Revenues
$enter a total net income or loss amount
Prepare a retained earnings statement for the year ending
December 31, 2017.
MONTY CORP.
Retained Earnings Statement
choose the accounting period
December 31, 2017
For the Year Ending December 31, 2017
For the Month Ending December 31, 2017
select an opening name
Dividends
Expenses
Net Income / (Loss)
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Revenues
Total Expenses
Total Revenues
$enter a dollar amount
select between addition and deduction
Add
Less
: select an item
Dividends
Expenses
Net Income / (Loss)
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Revenues
Total Expenses
Total Revenues
enter a dollar amount
select a closing name
Dividends
Expenses
Net Income / (Loss)
Retained Earnings, 1/1/17
Retained Earnings, 12/31/17
Revenues
Total Expenses
Total Revenues
$enter a total amount
In: Accounting
Practice object-oriented principles by making two Peanut Butter and Jelly Sandwiches. The program must create two sandwiches based on user input. The sandwich information for both must then print out their details and determine if the two sandwiches are equal.
Requirements:
Write a class called Bread with the following
o Calories: The number of calories per slice assumed to be between 50 and 250 inclusively.
Write a class called PeanutButter with the following
Write a class called Jelly with the following
Write a class called PBJSandwich with the following
Write a class called PBJFrontEnd with the following
Example Output:
-----------------------------------
Welcome to the PBJ Sandwich Maker!
-----------------------------------
-----Sandwich 1-----
Top Slice of Bread Information
Enter name of the bread
Wonder Bread
Enter the number of calories
80
Enter the type of bread. Must be "Honey Wheat", "White", "Whole Grain", or "Whole Wheat"
whole wheat
Peanut Butter Information
Enter name of the peanut butter
JIF
Enter the number of calories
190
Is it crunchy? Enter "true", or "false"
false
Jelly Information
Enter name of the jelly
Smuckers
Enter the number of calories
150
Enter the type of bread. Must be "Apple", "Blueberry", "Grape", "Strawberry", or "Tomato"
Apple
Bottom Slice of Bread Information
Enter name of the bread
Wonder Bread
Enter the number of calories
120
Enter the type of bread. Must be "Honey Wheat", "White", "Whole Grain", or "Whole Wheat"
honey Wheat
-----Sandwich 2-----
Top Slice of Bread Information
Enter name of the bread
Pepperidge Farm
Enter the number of calories
100
Enter the type of bread. Must be "Honey Wheat", "White", "Whole Grain", or "Whole Wheat"
Whole grain
Peanut Butter Information
Enter name of the peanut butter
Peter Pan
Enter the number of calories
180
Is it crunchy? Enter "true", or "false"
true
Jelly Information
Enter name of the jelly
Welch's
Enter the number of calories
150
Enter the type of bread. Must be "Apple", "Blueberry", "Grape", "Strawberry", or "Tomato"
Grape
Bottom Slice of Bread Information
Enter name of the bread
Lender's
Enter the number of calories
150
Enter the type of bread. Must be "Honey Wheat", "White", "Whole Grain", or "Whole Wheat"
Whole Wheat
-----Sandwich 1-----
PBJ Sandwich
Top Slice:
Bread
Name: Wonder Bread
Calories: 80
Type: whole wheat
Peanut Butter:
Peanut Butter
Name: JIF
Calories: 190
Is Crunchy: true
Jelly:
Jelly
Name: Smuckers
Calories: 100
Fruit Type: Apple
Bottom Slice:
Bread
Name: Wonder Bread
Calories: 120
Type: honey Wheat
-----Sandwich 2-----
PBJ Sandwich
Top Slice:
Bread
Name: Pepperidge Farm
Calories: 100
Type: Whole grain
Peanut Butter:
Peanut Butter
Name: Peter Pan
Calories: 180
Is Crunchy: true
Jelly:
Jelly
Name: Welch's
Calories: 100
Fruit Type: Grape
Bottom Slice:
Bread
Name: Lender's
Calories: 150
Type: Whole Wheat
Are they the same sandwich? false
Example Output 2:
-----------------------------------
Welcome to the PBJ Sandwich Maker!
-----------------------------------
-----Sandwich 1-----
Top Slice of Bread Information
Enter name of the bread
Wonder
Enter the number of calories
100
Enter the type of bread. Must be "Honey Wheat", "White", "Whole Grain", or "Whole Wheat"
White
Peanut Butter Information
Enter name of the peanut butter
JIF
Enter the number of calories
150
Is it crunchy? Enter "true", or "false"
false
Jelly Information
Enter name of the jelly
Welchs
Enter the number of calories
150
Enter the type of bread. Must be "Apple", "Blueberry", "Grape", "Strawberry", or "Tomato"
Grape
Bottom Slice of Bread Information
Enter name of the bread
Wonder
Enter the number of calories
100
Enter the type of bread. Must be "Honey Wheat", "White", "Whole Grain", or "Whole Wheat"
White
-----Sandwich 2-----
Top Slice of Bread Information
Enter name of the bread
Wonder
Enter the number of calories
100
Enter the type of bread. Must be "Honey Wheat", "White", "Whole Grain", or "Whole Wheat"
white
Peanut Butter Information
Enter name of the peanut butter
JIF
Enter the number of calories
150
Is it crunchy? Enter "true", or "false"
false
Jelly Information
Enter name of the jelly
Welchs
Enter the number of calories
150
Enter the type of bread. Must be "Apple", "Blueberry", "Grape", "Strawberry", or "Tomato"
grape
Bottom Slice of Bread Information
Enter name of the bread
wonder
Enter the number of calories
100
Enter the type of bread. Must be "Honey Wheat", "White", "Whole Grain", or "Whole Wheat"
white
-----Sandwich 1-----
PBJ Sandwich
Top Slice:
Bread
Name: Wonder
Calories: 100
Type: White
Peanut Butter:
Peanut Butter
Name: JIF
Calories: 150
Is Crunchy: true
Jelly:
Jelly
Name: Welchs
Calories: 100
Fruit Type: Grape
Bottom Slice:
Bread
Name: Wonder
Calories: 100
Type: White
-----Sandwich 2-----
PBJ Sandwich
Top Slice:
Bread
Name: Wonder
Calories: 100
Type: white
Peanut Butter:
Peanut Butter
Name: JIF
Calories: 150
Is Crunchy: true
Jelly:
Jelly
Name: Welchs
Calories: 100
Fruit Type: grape
Bottom Slice:
Bread
Name: wonder
Calories: 100
Type: white
Are they the same sandwich? true
In: Computer Science
In most supermarkets in the U.S., consumers are given the option of purchasing name brand products or store brand products. The name brand products are always priced higher than the store brand products, but in taste or quality tests, there is typically little to no difference between the two types. In fact, many store brand products are actually produced by name brand producers, but sold with the store’s label at a lower price.
a) Suppose the store brand and the name brand for a product, bread,
for example, are made by the same producer and are identical in
every way except for the label and price. The price of the store
brand is significantly less than the name brand. Why would any
consumer purchase the name brand?
b) What do you think has happened to the market shares of store brand products over the past 10 years? Why has this happened?
c) Consumer name brand products spend more than $20 billion/year on media advertising. Are these advertising expenditures wasteful from society’s perspective? Do consumers receive any benefits from this form of product differentiation?
In: Economics
Write a java program using the information given
Design a class named Pet, which should have the following fields (i.e. instance variables):
name - The name field holds the name of a pet (a String type)
type - The type field holds the type of animal that a pet is (a String type). Example values are
“Dog”, “Cat”, and “Bird”.
age - The age field holds the pet’s age (an int type)
Include accessor methods (i.e. get methods) and mutator methods (i.e. set methods) for all the fields.
Once you have designed the class, design a program that creates an object of the class and prompts the user to enter the name, type, and age of his or her pet. This data should be stored in the object. Use the object’s accessor methods to retrieve the pet’s name, type, and age and display this data on the screen.
Sample Output:
Enter the name of your pet: Jimmy
Enter the type of your pet: Dog
Enter the age of your pet: 5
Here is the information you provided:
Pet Name: Jimmy
Pet Type: Dog
Pet Age: 5
In: Computer Science
The three charges are at the three vertices of an equilateral triangle ?( all angles are 60degrees)
q 1 = + 10.0 µC
q 2 = - 5 .0 nC
q 3 = + 8 .0 nC
Equilateral side of the triangle = 0.05 m.
A. Draw forces acting on q 1 by q 2and q 3
B. find the components on X and Y axes .
C. Use Pythagorean theorem to find the resultant .
D. Use tangent to find the direction ( angle ) the resultant makes with horizontal.
q 3 q 1 q 2
2-A proton is released from rest between two conducting plates. The distance between the two plates is 6.0 cm how fast will the electron be moving reaches to the second plate. The potential difference between the two plates is 10 KV.
= 1.60 × 10-19C, m proton= 1.67 × 10-27kg)
Show formulas, substitution, and calculation with units.
-What are the currents in each resistor?
Voltage across the battery V = 12 volts
R1= 1?, R2= 2?, R3= 3?, R4= 4?, R5= 5?, R6= 6?,
4. In an RCseries circuit, V = 24.0 V, resistance R= 47 K?, and capacitance C= 2200 ?F.
Calculate the time constant.
Define time constant in a complete sentence.
C) How long does it take for the capacitor to reach to its 63% of its maximum charge?
d) How long does it take for the capacitor to reach to its 75% of it maximum charge?
e) How much charge can be stored in the capacitor after 50 seconds?
5. Find the electric potential of the following configuration at point P. The two short sides of the triangle are the same size = 23 cm.
Q1 = - 5600 nC
Q2 = - 2200 nC
Q1 Q2 p
F= K Q1Q2/ r2
E = K Q/ r2
V= K Q/ r
U or PE = Q V
KE = ½ m v2
R = R1+ R2+ ….
1/R = 1/R1+ 1/R2+….
FY F FX
FX= F Cos?
FY= F Sin?
F2= FX 2 + FY 2
Q = Qm ( 1/ e- t/ RC )
Q = C V
In: Physics
Suppose we need to construct a tin can with a fixed volume V cm3 in the shape of a cylinder with radius r cm and height h cm. (Here V should be regarded as a constant. In some sense, your answers should be independent of the exact value of V .) The can is made from 3 pieces of metal: a rectangle for the side and two circles for the top and bottom. Suppose that these must be cut out of a rectangular sheet of metal. Our goal is to find the values of r and h, and the dimensions of this rectangular sheet that minimize its area.
Draw a picture of how the rectangle and two circles could be cut out of a larger rectangle. There are multiple ways to do this (I can think of at least 3). Draw as many as you can, solve the problems below for each arrangement and then compare your answers.
Label the sides of the rectangle in terms of r and h. Express the rectangle’s area in terms of r and h. Also, note whether there are any assumptions about r and h that you need to make in order for your picture to make sense. (For example, if you draw a circle with diameter 2r inside of a rectangle with side l, then you must have 2r ≤ l.)
Use the fact that the can’s volume is V = πr2h to express h in terms of r, and write the rectangle’s area as a function of r. (Or else, you may alternatively solve for r and write the area as a function of h.)
Find the value of r (or h) that minimizes the rectangle’s area. What is the correspond- ing value of h (or r), and the dimensions of the rectangle? Your answers will most likely be in terms of V , but the ratio h/r might be a number. What is the minimum area of the rectangle in terms of V ?
As mentioned above, you should complete (1)-(4) for as many different arrangements as you can think of. (The math for some might be very simple.) Then compare your answers to find the best way of arranging the 2 circles and rectangle inside the larger rectangle, and the minimum possible area of the rectangle.
What if you need to make 2 (or more) cans in the same way. Can you find an arrangement of all the necessary pieces inside a single rectangle that is even more efficient?
In: Physics
package SOLUTION;
import java.util.Collection;
import java.util.Set;
public interface MapInterface<K, V> {
/**
* If the given key is not already in the map, adds
the
* key-value pair to the map. Otherwise, updates the
old
* value of the existing key to the specified
value.
* @param key the key
* @param value the value to be stored in the map with
the key
* @return null if the key was not already in the map,
or
* the old value associated with the key if the key was
already in the map
*/
public V put(K key, V value);
/**
* Gets the value from the map that is associated with
the given key
* @param key the key
* @return the value associated with the key, or null
if the key is
* not in the map
*/
public V get(K key);
/**
* Removes from the key-value pair associated with the
specified key
* @param key the key
* @return the value associated with the key, or null
if the key is
* not in the map
*/
public V remove(K key);
/**
* Returns whether the map contains the key-value pair
associated with
* the specified key
* @param key the key
* @return true if the map contains a key-value pair
with the specified
* key, and false otherwise
*/
public boolean containsKey(K key);
/**
* Returns whether the map contains no elements
* @return true if the map contains no key-value pairs,
and false otherwise
*/
public boolean isEmpty();
/**
* Removes all elements from the map
*/
public void clear();
/**
* Gets the number of key-value pairs in the map
* @return the number of key-value pairs in the
map
*/
public int size();
/**
* Gets a set of all keys in the map
* @return
*/
public Set<K> keySet();
/**
* Gets a set of all values in the map
* @return
*/
public Collection<V> values();
}
package SOLUTION;
public class Tester {
public static void main(String[] args) {
ArrayListMap<String, Integer>
alm = new ArrayListMap<String, Integer>();
System.out.println(alm.put("Cindy",
1));
System.out.println(alm.put("Nina",
2));
System.out.println(alm.put("Morgan", 3));
System.out.println(alm.put("Michael", 4));
System.out.println(alm.size());
System.out.println(alm.containsKey("Morgan"));
System.out.println(alm.containsKey("Jack"));
System.out.println(alm.get("Michael"));
System.out.println(alm.values());
System.out.println(alm.keySet());
System.out.println(alm.put("Michael", 6));
System.out.println(alm.get("Michael"));
System.out.println(alm.remove("Michael"));
System.out.println(alm.remove("Morgan"));
System.out.println(alm.remove("Nina"));
System.out.println(alm.remove("Cindy"));
System.out.println(alm.size());
}
}
In: Computer Science
1. Problems and Applications Q1
A publisher faces the following demand schedule for the next novel from one of its popular authors:
|
Price |
Quantity Demanded |
|---|---|
|
(Dollars) |
(Copies) |
| 40 | 0 |
| 36 | 50,000 |
| 32 | 100,000 |
| 28 | 150,000 |
| 24 | 200,000 |
| 20 | 250,000 |
| 16 | 300,000 |
| 12 | 350,000 |
| 8 | 400,000 |
| 4 | 450,000 |
| 0 | 500,000 |
The author is paid $800,000 to write the novel, and the marginal cost of publishing the novel is a constant $4 per copy.
Complete the second, fourth, and fifth columns of the following table by computing total revenue, total cost, and profit at each quantity.
|
Quantity |
Total Revenue |
Marginal Revenue |
Total Cost |
Profit |
|---|---|---|---|---|
|
(Copies) |
(Dollars) |
(Dollars) |
(Dollars) |
(Dollars) |
| 0 | ||||
| 50,000 | ||||
| 100,000 | ||||
| 150,000 | ||||
| 200,000 | ||||
| 250,000 | ||||
| 300,000 | ||||
| 350,000 | ||||
| 400,000 | ||||
| 450,000 | ||||
| 500,000 | ||||
Which of the following quantity–price combinations would a profit-maximizing publisher choose? (Note: If the publisher is indifferent between more than one choice, select all of the indifferent combinations.) Check all that apply.
150,000 copies at a price of $28
200,000 copies at a price of $24
250,000 copies at a price of $20
300,000 copies at a price of $16
Complete the third column of the previous table by computing marginal revenue. (Hint: Recall that MR=ΔTRΔQMR=ΔTRΔQ.)
True or False: At each quantity, marginal revenue is less than the price.
True
False
Use the black points (plus symbol) to graph the marginal revenue from the 50,000th, 100,000th, 150,000th, 200,000th, 250,000th, and 300,000th copy of the novel. Remember to plot from left to right and to plot between integers. For example, if the marginal revenue of increasing production from 50,000 copies to 100,000 copies were 10, then you would plot a point at (75, 10). Next use the orange line (square symbol) to graph the marginal-cost curve faced by the publisher. Finally, use the blue points (circle symbol) to graph demand at the following quantities (in thousands): 0, 50, 100, 150, 200, 250, 300, 350, 400, 450, and 500.
Marginal RevenueMarginal CostDemandDeadweight Loss0501001502002503003504004505004036322824201612840-4PriceQuantity (Thousands of copies)200, 24Y-Intercept: 4Slope: 0
The marginal-revenue and marginal-cost curves intersect at a quantity of copies.
On the previous graph, use the black triangle (plus symbols) to shade the area representing deadweight loss.
If the author were paid $1 million instead of $800,000 to write the book, the publisher would the price it charges for a copy of the novel.
Suppose the publisher was not profit-maximizing but was concerned with maximizing economic efficiency, and the author of a novel was paid $800,000 to write the book.
In this case, the publisher would charge
for a copy of the novel and earn a profit of
. (Note: If the publisher experiences a loss, be sure to enter a negative number for profit.)
In: Economics