Add a copy constructor for the linked list implementation below. Upload list.cpp with your code added. (DO NOT MODIFY THE HEADER FILE OR TEST FILE. only modify the list.cpp)
/*LIST.CPP : */
#include "list.h"
using namespace std;
// Node class implemenation
template <typename T>
Node<T>::Node(T element) { // Constructor
data = element;
previous = nullptr;
next = nullptr;
}
// List implementation
template <typename T>
List<T>::List() {
head = nullptr;
tail = nullptr;
}
template <typename T>
List<T>::List(const List& rhs) // Copy constructor -
homework
{
// Your code here
}
template <typename T>
List<T>::~List() { // Destructor
for(Node<T>* n = head; n != nullptr; n =
n->next) {
delete n;
}
}
template <typename T>
void List<T>::push_back(T element) {
Node<T>* new_node = new
Node<T>(element);
if (tail == nullptr) { // Empty list
head = new_node;
tail = new_node;
} else {
new_node->previous = tail;
tail->next = new_node;
tail = new_node;
}
}
template <typename T>
void List<T>::insert(Iterator<T> iter, T element)
{
if (iter.position == nullptr) {
push_back(element);
return;
}
Node<T>* after = iter.position;
Node<T>* before = after->previous;
Node<T>* new_node = new
Node<T>(element);
new_node->previous = before;
new_node->next = after;
after->previous = new_node;
if (before == nullptr) {
head = new_node;
} else {
before->next = new_node;
}
}
template <typename T>
Iterator<T> List<T>::erase(Iterator<T> iter)
{
Node<T>* remove = iter.position;
Node<T>* before = remove->previous;
Node<T>* after = remove->next;
if (remove == head) {
head = after;
} else {
before->next = after;
}
if (remove == tail) {
tail = before;
} else {
after->previous = before;
}
delete remove;
Iterator<T> r;
r.position = after;
r.container = this;
return r;
}
template <typename T>
Iterator<T> List<T>::begin() {
Iterator<T> iter;
iter.position = head;
iter.container = this;
return iter;
}
template <typename T>
Iterator<T> List<T>::end() {
Iterator<T> iter;
iter.position = nullptr;
iter.container = this;
return iter;
}
// Iterator implementation
template <typename T>
Iterator<T>::Iterator() {
position = nullptr;
container = nullptr;
}
template <typename T>
T Iterator<T>::get() const {
return position->data;
}
template <typename T>
void Iterator<T>::next() {
position = position->next;
}
template <typename T>
void Iterator<T>::previous() {
if (position == nullptr) {
position =
container->tail;
} else {
position =
position->previous;
}
}
template <typename T>
bool Iterator<T>::equals(Iterator<T> other) const
{
return position == other.position;
}
/*LIST.H :*/
// Doubly linked list
#ifndef LIST_H
#define LIST_H
template<typename T> class List;
template<typename T> class Iterator;
template <typename T>
class Node {
public:
Node(T element);
private:
T data;
Node* previous;
Node* next;
friend class List<T>;
friend class Iterator<T>;
};
template <typename T>
class List {
public:
List(); // Constructor
List(const List& rhs); // Copy
constructor - Homework
~List(); // Destructor
void push_back(T element); //
Inserts to back of list
void insert(Iterator<T> iter,
T element); // Insert after location pointed by iter
Iterator<T>
erase(Iterator<T> iter); // Delete from location pointed by
iter
Iterator<T> begin(); // Point
to beginning of list
Iterator<T> end(); // Point
to past end of list
private:
Node<T>* head;
Node<T>* tail;
friend class Iterator<T>;
};
template <typename T>
class Iterator {
public:
Iterator();
T get() const; // Get value pointed
to by iterator
void next(); // Advance iterator
forward
void previous(); // Advance
iterator backward
bool equals(Iterator<T>
other) const; // Compare values pointed to by two iterators
private:
Node<T>* position; // Node
pointed to by iterator
List<T>* container; // List
the iterator is used to iterattoe
friend class List<T>;
};
#endif
/*LIST TEST.CPP*/
// Test for templated linked list impementation
#include <iostream>
#include "list.h"
#include "list.cpp"
using namespace std;
int main() {
List<string> planets;
planets.push_back("Mercury");
planets.push_back("Venus");
planets.push_back("Earth");
planets.push_back("Mars");
for (auto p = planets.begin();
!p.equals(planets.end()); p.next())
cout << p.get() << "
";
cout << endl;
// Test erase
auto p = planets.begin();
// Erase earth
p.next(); p.next();
auto it = planets.erase(p);
cout << "Next in list: " << it.get()
<< endl;
// Test copy constructor - homework
List<string> planetsCopy(planets);
// Insert Earth into copy
p = planetsCopy.begin();
p.next();
planetsCopy.insert(p, "Earth");
// Print copied list - Should print: Mercury Earth
Venus Mars
for (auto p = planetsCopy.begin();
!p.equals(planetsCopy.end()); p.next())
cout << p.get() << "
";
cout << endl;
// Print original list - Should print: Mercury
Venus Mars
for (auto p = planets.begin();
!p.equals(planets.end()); p.next())
cout << p.get() << "
";
cout << endl;
}
In: Computer Science
|
Date |
Description |
Amount |
Days |
Interest |
In: Accounting
Please describe how you would account for the following:
A company's fixed asset policy is that they capitalize purchases > $2,500.
1. A laptop costing $2,000 is purchased Oct 1 2020. What are the journal entries for Oct, Nov, and Dec 2020?
2. A copier costing $5,500 is purchased Oct 15 2020. What are the journal entries for Oct, Nov, and Dec 2020?
In: Accounting
Protek Ltd, a masks distributor company, provides the following trial balance for the year ended 30 June 2020:
Protek Ltd
Trial balance as at 30 June 2020
Debit ($)
Credit ($)
Sales of N97 surgical masks
2,151,670
Sales of 4-ply masks
3,120,850
Sales of masks filters
3,288,426
Cost of goods sold
4,688,000
Rental expenses
375,950
Salaries and wages
1,980,000
Administration expenses
128,450
Annual leave expense
98,510
Doubtful debts expense
158,000
Depreciation expense
376,000
Amortisation expense - patent
56,900
Interest expense
22,500
Interest income
8,200
Selling expenses
66,800
Income tax expense
228,600
Cash on hand
53,000
Cash management account
230,000
Trade debtors
478,600
Allowance for doubtful debts
19,144
Inventories
455,040
Land
760,000
Motor vehicles
630,000
Accumulated depreciation - motor vehicles
252,000
Office equipment
620,000
Accumulated depreciation - office equipment
124,000
Patent (5 years)
569,000
Accumulated amortisation - patent
56,900
Deferred tax asset
28,500
Deferred tax liability
125,000
Bank loan
450,000
Trade creditors
182,560
Provision for annual leave
43,000
Current tax liability
132,100
Retained earnings, 1 July 2019
70,000
Dividends paid
20,000
Share capital
2,000,000
12,023,850
12,023,850
Additional information:
Protek Ltd is a reporting entity in accordance with the requirements of Australian’s Conceptual Framework.
The bank loan is repayable in 3 years.
The depreciation expense of $376,000 relates to motor vehicles and office equipment amounted to $252,000 and $124,000 respectively.
60% of the provision for annual leave are expected to be payable within 1 year and the remaining is payable after 1 year.
The patent was acquired on 1 January 2020. It represents fees paid to Teknova Group, a manufacturer company based in China. Protek Ltd is given the sole distributorship in Australia to sell the new high quality mask, N97, designed for first line workers in the health industry. The patent lasts for 5 years.
There was no new shares issued during the financial year ending 30 June 2020.
Protek Ltd uses the single statement format for the statement of profit or loss and other comprehensive income and presents an analysis of expenses by function on the statement.
The following expenses are allocated to administrative expenses and distribution costs for the purposes of preparation of the statement of profit or loss and other comprehensive income:
Administrative expenses
Distribution costs
Rental expenses
40%
60%
Salaries and wages
50%
50%
Administration expenses
100%
-
Annual leave expense
50%
50%
Doubtful debts expense
-
100%
Depreciation expense – motor vehicles
10%
90%
Depreciation expense – office equipment
80%
20%
Amortisation expense - patent
100%
-
Selling expenses
-
100%
In relation to the statement of financial position, where AASB 101 requires entities to disclose further sub-classifications of the minimum line items on the face of the statement or in the notes, the directors of Protek Ltd want to report only the minimum line items on the face of the statement, and leave the sub-classifications to be disclosed in the notes.
Part A
As the accountant for the entity, prepare the following statements of Protek Ltd the year ended 30 June 2020 in accordance with AASB101:
Statement of profit or loss and other comprehensive income;
Statement of financial position; and
Statement of changes in equity.
In preparing the above statements, you should use the line items that a listed company is likely to use and refer to paragraphs 54, 82, 82A and 106 of AASB 101 in determining the line items to be presented. Show all workings to support your figures presented in the statements. Disclosure notes and comparative figures are not required.
Note: In preparing the statements for Part A, you should consider only information given in this part and ignore information given in Part B below.
Part B
The following events occurred after the preparation of statements was completed in Part A above.
Event 1
The directors have asked you to review the doubtful debts allowance due to the high level of bad debts expense that occurred during the year. The allowance is currently measured based on 4% of trade debtors’ balances following the advice of Jane, who is one of the directors. After reviewing industry averages, you have advised the directors that the allowances should be revised to 8% of the trade debtors’ balances and the directors agreed to your proposal and adopt the new basis from 1 July 2019. This change is considered material in Protek Ltd’s case.
Required:
State if the above situation would constitute a change in accounting policy or a change in accounting estimate. Explain and support your answers by making reference to relevant paragraphs in AASB108.
Prepare necessary adjusting entries and/or notes disclosures required to account for the change in the doubtful debt allowance for the year ended 30 June 2020.
Event 2
Protek Ltd stored its masks in rented warehouses located in several locations. One of the warehouses in Orange was destroyed by bushfires on 29 July 2020. From the accounting records, there were 8,000 boxes of N95 masks stored in that warehouse, with cost of inventories valued at $120,000. Unfortunately, there was no insurance policy acquired to cover this loss and the loss is considered material for Protek Ltd.
The financial statements for the year ended 30 June 2020 were authorised for issue by the directors on 28 August 2020.
Required:
Classify the above event as either an adjusting or non-adjusting event after the end of the reporting period. Justify your answer by making reference to AASB110.
Consistent with your answer to (i) above, prepare any journal entries and/or note disclosures required to comply with the requirements of AASB110.
In: Accounting
Thorp Inc. maintains a defined benefit pension plan for its employees. Pension plan balances as at January 1, 2020 include:
|
Projected Benefit Obligation (PBO), January 1, 2020 |
$ 600,000 |
|
Plan assets at market-related value, January 1, 2020 |
$ 550,000 |
|
Prior service cost (PSC- OCI)1 |
$ 150,000 |
|
Average remaining service period |
15 years |
|
Service cost |
$ 90,000 |
|
Expected returns on plan assets |
8% |
|
Actual returns earned on plan assets |
$40,000 |
|
Actuarial interest rate |
4% |
|
Contributions paid |
$ 150,000 |
|
Benefits to retirees in 2020 |
$ 100,000 |
|
Loss from change in actuarial assumption, December 31, 2020 |
$ 46,000 |
1 These prior service costs are from 2019 and already included in PBO on January 1,2020.
Required:
In: Accounting
accounting question
On 1 April 2010 Parent Ltd acquired 90% of the equity in Subsidiary Ltd for $650 000 cash. At this date the equity of Subsidiary Ltd comprised:
|
Share capital |
$500 000 |
|
Retained earnings |
130 000 |
Part A
(a) Assume the net assets of Subsidiary Ltd were at fair value on 1 April 2010. Prepare the notional journal entry to offset the carrying amount of the asset Investment in Subsidiary Ltd and the parent’s portion of equity in Subsidiary Ltd in accordance with the requirements of NZ IFRS 3 Business Combinations and NZ IFRS 10 Consolidated Financial Statements.
(b) Assume the net assets of Subsidiary Ltd were not at fair value on 1 April 2010. At the date of acquisition Subsidiary Ltd had an unrecognised intangible asset of $22 000 and a contingent liability of $8 000. Prepare the notional journal entry to offset the carrying amount of the asset Investment in Subsidiary Ltd and the parent’s portion of equity in Subsidiary Ltd in accordance with the requirements of NZ IFRS 3 Business Combinations and NZ IFRS 10 Consolidated Financial Statements.
(c) Briefly explain why the amount of acquired goodwill recognised above in (a) and (b) will not be the same amount.
Part B
Assume the net assets of Subsidiary Ltd were at fair value on 1 April 2010. Prepare the notional journal entry to identify the non-controlling interest (NCI) in Subsidiary Ltd to be reported in the group accounts as at 31 March 2017 in accordance with the requirements of NZ IFRS 3 Business Combinations and NZ IFRS 10 Consolidated Financial Statements. Parent Ltd measures the NCI at the NCI’s proportionate share of the acquiree’s identifiable net assets.
Additional information provided for Part B:
(i) During March 2016 Subsidiary Ltd made sales to Parent Ltd and realised a profit of
$2 000. At 31 March 2016 this purchase was included in the inventory balance of Parent Ltd.
(ii) During March 2017 Subsidiary Ltd made sales to Parent Ltd and realised a profit of
$3 000. Parent Ltd had not sold this purchase of inventory by 31 March 2017.
(iii) At the date of consolidation 31 March 2017 the equity of Subsidiary Ltd comprised:
|
Share capital |
$500 000 |
|
|
Retained earnings - opening |
145 000 |
|
|
Profit after tax |
62 000 |
|
|
Dividends declared and paid |
35 000 |
172 000 |
|
ARS |
30000 |
|
|
Total equity |
702 000 |
(iv) The directors of Parent Ltd believe the acquired goodwill in Subsidiary Ltd was impaired by $4 500 in the year ended 31 March 2017.
|
Part A (a) ALL workings must be shown on each line of your notional journal entry below. These workings will be marked. |
||
|
Part A (b) ALL workings must be shown on each line of your notional journal entry below. These workings will be marked. |
||
Question 1 continued:
|
Part A (c) Explanation: |
|
Part B ALL workings must be shown on each line of your notional journal entry below. These workings will be marked. |
||
In: Accounting
Jason Company offered a contest in which the winner would receive P1,000,000 payable over twenty years. On December 31, 2019, Jason Company announced the winner of the contest and signed a note payable to the winner for P1,000,000 payable in P50,000 installments every January 31. On December 31, 2019, Jason Company purchased an annuity for P418,250 to provide the P950,000 prize remaining after the first P50,000 installment which was paid on January 31, 2020. On December 31, 2019, what amount should be reported as note payable-contest winner, net of current portion?
In: Accounting
Coronado’s Agency sells an insurance policy offered by Capital Insurance Company for a commission of $103 on January 2, 2020. In addition, Coronado will receive an additional commission of $12 each year for as long as the policyholder does not cancel the policy. After selling the policy, Coronado does not have any remaining performance obligations. Based on Coronado’s significant experience with these types of policies, it estimates that policyholders on average renew the policy for 4.5 years. It has no evidence to suggest that previous policyholder behavior will change Determine the transaction price of the arrangement for Coronado, assuming 75 policies are sold.
In: Accounting
In: Accounting
|
Question 5 On January 1, 2020, Splish Company purchased $350,000, 8% bonds of Aguirre Co. for $322,973. The bonds were purchased to yield 10% interest. Interest is payable semiannually on July 1 and January 1. The bonds mature on January 1, 2025. Splish Company uses the effective-interest method to amortize discount or premium. On January 1, 2022, Splish Company sold the bonds for $324,733 after receiving interest to meet its liquidity needs. |
| (e) | Prepare the journal entry to record the sale of the bonds on January 1, 2022. |
In: Accounting