NEED TO BE IN PYTHON!!!
Make sure to put the main section of your code in the following if
block:
# Type code for classes here
if __name__ == "__main__":
# Type main section of code here
(1) Build the Account class with the following specifications:
Attributes
Create a constructor that has 3 parameters (in addition to self) that will be passed in from the user. (no default values)
Define a __str__() method to print an Account like the following
Account Name: Trish Duce
Account Number: 90453889
Account Balance: $100.00
Define a deposit() method that has 1 parameter (in addition to self) that will be passed in from the user. (no default values) The method deposits the specified amount in the account.
Define a withdraw() method that has 2 parameters (in addition to self) that will be passed in from the user. (no default values) The method withdraws the specified amount (1st parameter) and fee (2nd parameter) from the account.
(2) In the main section of your code, create 3 accounts.
(3) Print the 3 accounts using print(acct1)…
(4) Deposit 25.85, 75.50 and 50 into accounts 1, 2 and 3.
(5) Print the 3 accounts.
(6) Withdraw 25.85 (2.50 fee), 75.50 (1.50 fee), 50.00 (2.00 fee).
(7) Print the 3 accounts.
Output should look like the following:
Account Name: Trish Duce
Account Number: 90453889
Account Balance: $100.00
Account Name: Donald Duck
Account Number: 83504837
Account Balance: $100.00
Account Name: Joe Smith
Account Number: 74773321
Account Balance: $100.00
Account Name: Trish Duce
Account Number: 90453889
Account Balance: $125.85
Account Name: Donald Duck
Account Number: 83504837
Account Balance: $175.50
Account Name: Joe Smith
Account Number: 74773321
Account Balance: $150.00
Account Name: Trish Duce
Account Number: 90453889
Account Balance: $97.50
Account Name: Donald Duck
Account Number: 83504837
Account Balance: $98.50
Account Name: Joe Smith
Account Number: 74773321
Account Balance: $98.00
In: Computer Science
You will use the definition of the linked-queue from lab6, and re-write it as a template for a linked-queue (I hope you finished the function definitions)
In the driver file, create and use queues of different types to show it works.
In the documentation, indicate if there are any types it won’t work for, and why not.
driver.cpp
#include <iostream>
using namespace std;
#include "LQueue.h"
void print(Queue q)
{
q.display(cout);
}
int main()
{
Queue q1;
cout << "Queue created. Empty? " << boolalpha <<
q1.empty() << endl;
cout << "How many elements to add to the queue? ";
int numItems;
cin >> numItems;
for (int i = 1; i <= numItems; i++)
q1.enqueue(100 * i);
cout << "Contents of queue q1 (via print):\n";
print(q1); cout << endl;
Queue q2;
q2 = q1;
cout << "Contents of queue q2 after q2 = q1 (via
print):\n";
print(q2); cout << endl;
cout << "Queue q2 empty? " << q2.empty() <<
endl;
cout << "Front value in q2: " << q2.front() <<
endl;
while (!q2.empty())
{
cout << "Remove front -- Queue contents: ";
q2.dequeue();
q2.display(cout);
}
cout << "Queue q2 empty? " << q2.empty() <<
endl;
cout << "Front value in q2?" << endl <<
q2.front() << endl;
cout << "Trying to remove front of q2: " << endl;
q2.dequeue();
return 0;
}
LQueue.h
#include <iostream>
#ifndef LQUEUE
#define LQUEUE
typedef int QueueElement;
class Queue
{
public:
/***** Function Members *****/
/***** Constructors *****/
Queue();
/*-----------------------------------------------------------------------
Construct a Queue object.
Precondition: None.
Postcondition: An empty Queue
object has been constructed.
(myFront and myBack are initialized to null pointers).
-----------------------------------------------------------------------*/
Queue(const Queue & original);
/*-----------------------------------------------------------------------
Copy Constructor
Precondition: original is the queue
to be copied and is received
as a
const reference parameter.
Postcondition: A
copy of original has been constructed.
-----------------------------------------------------------------------*/
/***** Destructor *****/
~Queue();
/*-----------------------------------------------------------------------
Class destructor
Precondition: None.
Postcondition: The linked list
in the queue has been deallocated.
-----------------------------------------------------------------------*/
/***** Assignment *****/
const Queue & operator= (const Queue &
rightHandSide);
/*-----------------------------------------------------------------------
Assignment Operator
Precondition: rightHandSide is the
queue to be assigned and is
received as a const reference parameter.
Postcondition: The
current queue becomes a copy of rightHandSide
and a reference to it is returned.
-----------------------------------------------------------------------*/
bool empty() const;
/*-----------------------------------------------------------------------
Check if queue is empty.
Precondition: None.
Postcondition: Returns true if
queue is empty and false otherwise.
-----------------------------------------------------------------------*/
void enqueue(const QueueElement & value);
/*-----------------------------------------------------------------------
Add a value to a queue.
Precondition: value is to be
added to this queue.
Postcondition: value is added at
back of
queue.
-----------------------------------------------------------------------*/
void display(ostream & out) const;
/*-----------------------------------------------------------------------
Display values stored in the queue.
Precondition: ostream out is
open.
Postcondition: Queue's contents,
from front to back, have been
output to out.
-----------------------------------------------------------------------*/
QueueElement front() const;
/*-----------------------------------------------------------------------
Retrieve/Peep value at front of queue (if
any).
Precondition: Queue is
nonempty.
Postcondition: Value at front of
queue is returned, unless the queue
is empty; in that case, an error
message is displayed and a
"garbage value" is
returned.
-----------------------------------------------------------------------*/
void dequeue();
/*-----------------------------------------------------------------------
Remove value at front of queue (if any).
Precondition: Queue is
nonempty.
Postcondition: Value at front of
queue has been removed, unless
queue is empty; in that case, an
error message is displayed
and execution allowed to
proceed.
-----------------------------------------------------------------------*/
private:
void delete_q(); // utility/helper function to delete queues
for
// destructor and assignment
operator
/*** Node class for the
queue***/
class Node
{
public:
QueueElement data;
Node * next;
//--- Node constructor
Node(QueueElement value, Node * link = 0)
/*-------------------------------------------------------------------
Precondition: value and link are received
Postcondition: A Node has been constructed with value in its
data part and its next part
set to link (default 0).
------------------------------------------------------------------*/
{
data = value; next = link;
}
}; //for Node class
typedef Node * NodePointer;
/***** Data Members *****/
NodePointer myFront, // pointer to
front of queue
myBack;
// pointer to back of queue
}; // end of class declaration
#endif
LQueue-Incomplete.cpp
#include <new>
using namespace std;
#include "LQueue.h"
//--- Definition of Queue constructor
Queue::Queue()
: myFront(0), myBack(0)
{}
//--- Definition of Queue copy constructor
Queue::Queue(const Queue & original)
{
myFront = myBack = 0;
if (!original.empty())
{
// Copy first node
myFront = myBack = new Node(original.front());
// Set pointer to run through original's linked
list
NodePointer origPtr = original.myFront->next;
while (origPtr != 0)
{
myBack->next = new
Node(origPtr->data);
myBack = myBack->next;
origPtr = origPtr->next;
} //while
} //if
}
void Queue::delete_q(void) {
// Set pointer to run through the queue
NodePointer prev = myFront, // node to be released/deleted
ptr; // points to the front node
while (prev != 0)
{
ptr = prev->next;
delete prev;
prev = ptr;
}
}
//--- Definition of Queue destructor
// delete queue from the front
Queue::~Queue()
{
delete_q();
}
//--- Definition of assignment operator
const Queue & Queue::operator=(const Queue &
rightHandSide)
{
if (this !=
&rightHandSide)
// check that not q = q
{
this->delete_q();
// destroy current linked list
if
(rightHandSide.empty()) //
empty queue
myFront = myBack = 0;
else
{
// copy rightHandSide's list
//
Copy first node
myFront = myBack = new
Node(rightHandSide.front());
// Set pointer to run through rightHandSide's
linked list
NodePointer rhsPtr =
rightHandSide.myFront->next;
while (rhsPtr != 0)
{
myBack->next = new
Node(rhsPtr->data);
myBack = myBack->next;
rhsPtr = rhsPtr->next;
}
}
}
return *this;
}
//--- Definition of empty()
bool Queue::empty() const
{
return (myFront == 0);
}
//--- Definition of enqueue()
void Queue::enqueue(const QueueElement & value)
{
NodePointer newptr = new Node(value);
if (empty())
myFront = myBack = newptr;
else
{
myBack->next = newptr;
myBack = newptr;
}
}
//--- Definition of display()
void Queue::display(ostream & out) const
{
NodePointer ptr;
for (ptr = myFront; ptr != 0; ptr = ptr->next)
out << ptr->data << " ";
out << endl;
}
//--- Definition of front()
// Peep the first element of the queue
QueueElement Queue::front() const
{
if (!empty())
return (myFront->data);
else
{
cerr << "*** Queue is empty "
" -- returning garbage ***\n";
QueueElement * temp = new(QueueElement);
QueueElement garbage = *temp;
// "Garbage" value
delete temp;
return garbage;
}
}
//--- Definition of dequeue()
// simply decrement the queue
void Queue::dequeue()
{
if (!empty())
{
NodePointer ptr = myFront;
myFront = myFront->next;
delete ptr;
if (myFront == 0) // queue is
now empty
myBack = 0;
}
else
cerr << "*** Queue is empty -- can't remove a
value ***\n";
}
In: Computer Science
A box with an inertia of 2kg is held on a 1m high table against a spring with k = 75N which is initially compressed 0.5m. The coefficient of friction between the box and the table is 0.2. The spring is released, and it pushes the box until it reaches its equilibrium length. At this point, the spring is stopped by a stopper and the box continues to slide across the table with only the force of friction acting on it. After losing contact with the spring, the box travels the distance of the rest of the table, another 0.5m, where it then flies off the end of the table and lands on the floor. Assuming no air resistance,
(a) What was the net work done on the box while it was being pushed by the spring?
(b) What was the net work done on the box from the time it left the spring until it reached the edge of the table?
(c) How fast was the box moving when it flew off the table?
(d) How far from the table did the box land?
In: Physics
Construction project requires an intial investment of $900,000,
has a nine-year life, and salvage value is Zero. Sales are
projected at 75,000 units per year. Price per unit is $47, variable
cost per unit is $34, and fixed costs are $825,000 per year. The
tax rate is 35%, and discount rate is 15%. Using straight-line
depreciation method:
1. Calculate the accounting break-even point in number of units,
what is the degree of operating leverage at the accounting
break-even point
2. Calculate the OCF, NPV
3. Calculate the financial break-even point in number of
units
In: Accounting
In: Biology
Q1) Pennell Company gathered the following information for the year ended December 31, 2014:
|
Fixed costs: |
|
|
Manufacturing |
$300,000 |
|
Marketing |
100,000 |
|
Administrative |
50,000 |
|
Variable costs: |
|
|
Manufacturing |
$230,000 |
|
Marketing |
90,000 |
|
Administrative |
100,000 |
During the year, Pennell produced and sold 70,000 units of product at a sale price of $15.00 per unit. There was no beginning inventory of product on January 1, 2014.
Required:
______________________________________________________________
Q2)Print House, Inc., produces and sells laser jet printers for $1,400 each. The variable costs of each printer total $1,000 while total annual fixed costs are $300,000. Company’s profit for 2008 is $200,000.
Required:
a) Compute the Company’s break-even point in units and dollars.
b) What is the Company’s margin of safety in units, dollars, and percentage?
c) Compute the Company’s Sales for 2008.
In: Accounting
1. When 100.0 mL of a 0.135 M Ca(NO3)2 (MM = 164.088 g/mol) solution is added to 50.0 mL of a 0.575 M K3PO4 (MM = 212.27 g/mol) solution, what mass of calcium phosphate (MM = 310.17 g/mol) will precipitate?
2. What is the final Na+ concentration if 17.0 mL of a 3.12 M NaCl solution is added to 83.0 mL of a 1.18 M Na2SO4 solution?
In: Chemistry
In: Chemistry
Hello,
How can we create two buttons in a single page side by side through html?And how can we enter different data for different buttons, so that if i click 1st button it should show specific data and if i click second it should show other data?
In: Computer Science
Selected ratios for 2018 for two companies in the same industry are presented below:
| Ratio | Potter | Draco | Industry Average |
| Asset turnover | 2.7x | 2.3x | 2.5x |
| Average collection period | 31 days | 35 days | 38 days |
| Basic Earnings per share | $2.75 | $1.25 | Not available |
| Current Ratio | 1:9:1 | 3:0:1 | 1:8:1 |
| Dividend yield | 0.3% | 0.1% | 0.2% |
| Debt to total assets | 48% | 32% | 45% |
| Gross profit margin | 30% | 34% | 33% |
| Inventory turnover | 10x | 7x | 8x |
| Payout ratio | 9% | 19% | 14% |
| Price-earnings ratio | 29x | 45x | 38x |
| Profit margin | 8% | 6% | 5% |
| Return on assets | 12% | 10% | 10% |
| Return on common shareholders' equity | 24% | 16% | 18% |
| Time interest earned | 5.2x | 7.6x | 7.2x |
REQUIRED: Answer each of the following questions providing the ratio(s) to support your answer, explain.
1) Comment on how successful each company appears to managing
its accounts receivable. Terms are net 30 for both companies
2) How well does each company appear to be managing its
inventory?
3) Which company is more solvent, explain using
ratios?
4) Which company is more profitable, explain using ratios?
5) The gross profit margin for Draco is higher than Potter's and
the industry average. Provide two reasons why this would be the
case?
6) Which company would investors believe would have greater
prospects for seeking growth?
7) Why is Basic Earnings per Share not comparable between
companies?
In: Accounting
Question about wave propagation
In: Physics
All the energy investment reactions involve _______.
A. isomerase
B. kinase
C. dehydrogenase
D. aldolase
In: Biology
2. Based on the Slutsky Equation and relevant theorems, discuss in your own words about the reactions of quantity demanded to price and income changes (Law of Demand - Theorem 1.13).
In: Economics
13. When the output gap is _______ (an inflationary gap), the unemployment rate is below the natural rate. When the output gap is _______ (a recessionary gap), the unemployment rate is above the natural rate.
A) positive; positive
B) negative; negative
C) positive; negative
D) negative; positive
14. Along a Phillips curve:
A) consumption depends on prices.
B) the inflation rate varies inversely with the unemployment rate.
C) the inflation rate varies directly with the unemployment rate.
D) prices and tax rates are directly related.
15. An increase in the expected rate of inflation would:
A) shift the short-run Phillips curve downward.
B) shift the short-run Phillips curve upward.
C) move the economy along the short-run Phillips curve to higher rates of inflation.
D) move the economy along the short-run Phillips curve to higher rates on unemployment.
16. The long-run Phillips curve is:
A) the same as the short-run Phillips curve.
B) negatively sloped, showing an inverse relationship between unemployment and inflation.
C) vertical at the non accelerating-inflation rate of unemployment (NAIRU).
D) unrelated to the NAIRU.
17. When the economic situation is such that monetary policy can no longer be used because the nominal rate of interest cannot fall below zero, it is called:
A) the liquidity preference.
B) the money neutrality.
C) the liquidity trap.
D) the money illusion.
18. The NAIRU is:
A) the inflation rate at which the unemployment rate does not change over time.
B) a trade-off between unemployment and inflation.
C) the unemployment rate at which inflation does not change over time.
D) a rate at which it is possible to achieve lower unemployment by accepting higher inflation.
19. If the economy is currently in a recessionary gap, real GDP will be________potential output.
A) below
B) the same as
C) above
D) in equilibrium with
20. If the SRAS curve intersects the aggregate demand curve to the right of LRAS, the result will be:
A) a recessionary gap.
B) an inflationary gap.
C) cyclical unemployment.
D) Long-run equilibrium.
In: Economics
an ideal gas has C_v=(7/2)R. A 2.00 mole sample of gas starts at P=1*10^5 Pa and T=300K. determine the total P, V&T for each of the following cases, as well as ΔE_int, W and Q
a) gas is heated at constant P to 400K
b) gas is heated at constant V to 400K
c) isothermal conpression to P=1.2*10^5 Pa
d) adiabatic to compression P= 1.2*10^5
In: Physics