SlideShare a Scribd company logo
Please the following is the currency class of perious one.
class Currency {
protected:
int whole;
int fraction;
virtual std::string get_name() = 0;
public:
Currency() {
whole = 0;
fraction = 0;
}
Currency(double value) {
if (value < 0)
throw "Invalid value";
whole = int(value);
fraction = std::round(100 * (value - whole));
}
Currency(const Currency& curr) {
whole = curr.whole;
fraction = curr.fraction;
}
/* This algorithm gets the whole part or fractional part of the currency
Pre: whole, fraction - integer numbers
Post:
Return: whole or fraction
*/
int get_whole() { return whole; }
int get_fraction() { return fraction; }
/* This algorithm adds an object to the same currency
Pre: object (same currency)
Post:
Return:
*/
void set_whole(int w) {
if (w >= 0)
whole = w;
}
void set_fraction(int f) {
if (f >= 0 && f < 100)
fraction = f;
}
/* This algorithm adds an object to the same currency
Pre: object (same currency)
Post:
Return:
*/
void add(const Currency* curr) {
whole += curr->whole;
fraction += curr->fraction;
if (fraction > 100) {
whole++;
fraction %= 100;
}
}
/* This algorithm subtracts an object to the same currency
Pre: object (same currency)
Post:
Return:
*/
void subtract(const Currency* curr) {
if (!isGreater(*curr))
throw "Invalid Subtraction";
whole -= curr->whole;
if (fraction < curr->fraction) {
fraction = fraction + 100 - curr->fraction;
whole--;
}
else {
fraction -= curr->fraction;
}
}
/* This algorithm compares the an object of the same currency for equality or inequality
Pre: object (same currency)
Post:
Return: whole/fraction
*/
bool isEqual(const Currency& curr) {
return curr.whole == whole && curr.fraction == fraction;
}
/* This algorithm compares the an object of the same currency to determine which is greater or
smaller
Pre: object (same currency)
Post:
Return: true/false
*/
bool isGreater(const Currency& curr) {
if (whole < curr.whole)
return false;
if (whole == curr.whole && fraction < curr.fraction)
return false;
return true;
}
/* This algorithm prints the name and value of the currency object
Pre: value of whole, fraction, and the name
Post: whole, fraction, get_name()
Return:
*/
void print() {
std::cout << whole << "." << fraction << " " << get_name() << std::endl;
}
};
class Krone : public Currency {
protected:
/*
This algorithm gets the name for the Currency.
Pre: name - declared as string and initialized as Krone
Post:
Return: name
*/
std::string name = "Krone";
std::string get_name() {
return name;
}
public:
Krone() : Currency() { }
Krone(double value) : Currency(value) { }
Krone(Krone& curr) : Currency(curr) { }
};
class Soum : public Currency {
protected:
/* This algorithm gets the name for the Currency.
Pre: name - declared as string and initialized as Soum
Post:
Return: name
*/
std::string name = "Soum";
std::string get_name() {
return name;
}
public:
Soum() : Currency() { }
Soum(double value) : Currency(value) { }
Soum(Krone& curr) : Currency(curr) { }
};
A LinkNode structure or class which will have two attributes -
a data attribute, and
a pointer attribute to the next node.
The data attribute of the LinkNode should be a reference/pointer of the Currency class of Lab 2.
Do not make it an inner class or member structure to the SinglyLinkedList class of #2 below.
A SinglyLinkedList class which will be composed of three attributes -
a count attribute,
a LinkNode pointer/reference attribute named as and pointing to the start of the list and
a LinkNode pointer/reference attribute named as and pointing to the end of the list.
Since this is a class, make sure all these attributes are private.
The class and attribute names for the node and linked list are the words in bold in #1 and #2.
For the Linked List, implement the following linked-list behaviors as explained in class -
getters/setters/constructors/destructors, as needed, for the attributes of the class.
createList method in addition to the constructor - this is optional for overloading purposes.
destroyList method in place of or in addition to the destructor - this is optional for overloading
purposes,
addCurrency method which takes a Currency object and a node index value as parameters to add
the Currency to the list at that index.
removeCurrency method which takes a Currency object as parameter and removes that Currency
object from the list and may return a copy of the Currency.
removeCurrency overload method which takes a node index as parameter and removes the
Currency object at that index and may return a copy of the Currency.
findCurrency method which takes a Currency object as parameter and returns the node index at
which the Currency is found in the list.
getCurrency method which takes an index values as a parameter and returns the Currency object.
printList method which returns a string of all the Currency objects in the list in the order of
index, tab spaced.
isListEmpty method which returns if a list is empty or not.
countCurrency method which returns a count of Currency nodes in the list.
Any other methods you think would be useful in your program.
A Stack class derived from the SinglyLinkedList but with no additional attributes and the usual
stack methods -
constructor and createStack (optional) methods,
push which takes a Currency object as parameter and adds it to the top of the stack.
pop which takes no parameter and removes and returns the Currency object from the top of the
stack.
peek which takes no parameter and returns a copy of the Currency object at the top of the stack.
printStack method which returns a string signifying the contents of the stack from the top to
bottom, tab spaced.
destructor and/or destroyStack (optional) methods.
Ensure that the Stack objects do not allow Linked List functions to be used on them.
A Queue class derived from the SinglyLinkedList but with no additional attributes and the usual
queue methods -
constructor and createQueue (optional) methods,
enqueue which takes a Currency object as parameter and adds it to the end of the queue.
dequeue which takes no parameter and removes and returns the Currency object from the front of
the queue.
peekFront which takes no parameter and returns a copy of the Currency object at the front of the
queue.
peekRear which takes no parameter and returns a copy of the Currency object at the end of the
queue.
printQueue method which returns a string signifying the contents of the queue from front to end,
tab spaced.
destructor and/or destroyQueue (optional) methods.
Ensure that the Queue objects do not allow Linked List functions to be used on them.
Ensure that all your classes are mimimal and cohesive with adequate walls around them. Make
sure to reuse and not duplicate any code.
Then write a main driver program that will demonstrate all the capabilities of your ADTs as
follows -
First, print a Welcome message for the demonstration of your ADTs - you can decide what the
message says but it should include your full name(s).
Second, create the following twenty (20) Krone objects in a Currency array to be used in the
program.
Kr 57.12
Kr 23.44
Kr 87.43
Kr 68.99
Kr 111.22
Kr 44.55
Kr 77.77
Kr 18.36
Kr 543.21
Kr 20.21
Kr 345.67
Kr 36.18
Kr 48.48
Kr 101.00
Kr 11.00
Kr 21.00
Kr 51.00
Kr 1.00
Kr 251.00
Kr 151.00
Then, create one each of SinglyLinkedList, Stack and Queue objects.
For the linked list, perform the following operations in order -
Add the first seven (7) objects from the array into the linked list in order such that they end up in
the reverse order in the linked list, i.e. the seventh element as first node and first element as
seventh node. If it is easier, you are allowed to insert copies of the objects.
Search for Kr 87.43 followed by Kr 44.56 - print the results of each.
Remove the node containing Kr 111.22 followed by the node at index 2.
Print the contents of the list.
Then add the next four (4) objects (#9 thru 12) such that their index in the linked list is calculated
as (index in array % 5).
Remove two (2) objects at indexes (countCurrency % 6) and (countCurrency / 7) in that order.
Print the contents of the list.
For the stack, perform the following operations in order -
Push seven (7) objects starting from the array index 13 onwards to the stack.
Peek the top of the stack - print the result.
Perform three (3) pops in succession.
Print the contents of the stack.
Push five (5) more objects from the start of the objects array to the stack.
Pop twice in succession.
Print the contents of the stack.
For the queue, perform the following operations in order -
Enqueue the seven (7) objects at odd indexes starting from index 5 in the array.
Peek the front and end of the queue - print the results.
Perform two (2) dequeues in succession.
Print the contents of the queue.
Enqueue five (5) more objects from the index 10 in the array.
Dequeue three times in succession.
Print the contents of the queue.
End the program with a leaving message of your choice. Remember to clean up before the
program ends.
Restrict all your input / output to the main driver program only, except for the existing screen
print inside the Currency print methods.

More Related Content

Similar to Please the following is the currency class of perious one- class Curre.pdf

Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
info114
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
info309708
 
Create a Queue class that implements a queue abstraction. A queue is.docx
Create a Queue class that implements a queue abstraction. A queue is.docxCreate a Queue class that implements a queue abstraction. A queue is.docx
Create a Queue class that implements a queue abstraction. A queue is.docx
rajahchelsey
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdf
herminaherman
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
adityastores21
 
I am trying to fill out a program where the method definitions will b.docx
I am trying  to fill out a program where the method definitions will b.docxI am trying  to fill out a program where the method definitions will b.docx
I am trying to fill out a program where the method definitions will b.docx
Phil4IDBrownh
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
aathmaproducts
 
Stata Programming Cheat Sheet
Stata Programming Cheat SheetStata Programming Cheat Sheet
Stata Programming Cheat Sheet
Laura Hughes
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
aathiauto
 
For C# need to make these changes to this programm, httppastebin..pdf
For C# need to make these changes to this programm, httppastebin..pdfFor C# need to make these changes to this programm, httppastebin..pdf
For C# need to make these changes to this programm, httppastebin..pdf
fathimafancyjeweller
 
Chapter 2
Chapter 2Chapter 2
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
afgt2012
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
contact41
 
03. Week 03.pptx
03. Week 03.pptx03. Week 03.pptx
03. Week 03.pptx
Vinc2ntCabrera
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
TechMagic
 
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfIn C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
stopgolook
 
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 Sorted number list implementation with linked listsStep 1 Inspec.pdf Sorted number list implementation with linked listsStep 1 Inspec.pdf
Sorted number list implementation with linked listsStep 1 Inspec.pdf
almaniaeyewear
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdf
mohdjakirfb
 
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbqueuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
RAtna29
 
Stata cheatsheet programming
Stata cheatsheet programmingStata cheatsheet programming
Stata cheatsheet programming
Tim Essam
 

Similar to Please the following is the currency class of perious one- class Curre.pdf (20)

Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdfNeed done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
Need done for Date Structures please! 4-18 LAB- Sorted number list imp.pdf
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
 
Create a Queue class that implements a queue abstraction. A queue is.docx
Create a Queue class that implements a queue abstraction. A queue is.docxCreate a Queue class that implements a queue abstraction. A queue is.docx
Create a Queue class that implements a queue abstraction. A queue is.docx
 
For this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdfFor this homework, you will write a program to create and manipulate.pdf
For this homework, you will write a program to create and manipulate.pdf
 
maincpp Build and procees a sorted linked list of Patie.pdf
maincpp   Build and procees a sorted linked list of Patie.pdfmaincpp   Build and procees a sorted linked list of Patie.pdf
maincpp Build and procees a sorted linked list of Patie.pdf
 
I am trying to fill out a program where the method definitions will b.docx
I am trying  to fill out a program where the method definitions will b.docxI am trying  to fill out a program where the method definitions will b.docx
I am trying to fill out a program where the method definitions will b.docx
 
Need to be done in C Please Sorted number list implementation with.pdf
Need to be done in C  Please   Sorted number list implementation with.pdfNeed to be done in C  Please   Sorted number list implementation with.pdf
Need to be done in C Please Sorted number list implementation with.pdf
 
Stata Programming Cheat Sheet
Stata Programming Cheat SheetStata Programming Cheat Sheet
Stata Programming Cheat Sheet
 
Need to be done in C++ Please Sorted number list implementation wit.pdf
Need to be done in C++  Please   Sorted number list implementation wit.pdfNeed to be done in C++  Please   Sorted number list implementation wit.pdf
Need to be done in C++ Please Sorted number list implementation wit.pdf
 
For C# need to make these changes to this programm, httppastebin..pdf
For C# need to make these changes to this programm, httppastebin..pdfFor C# need to make these changes to this programm, httppastebin..pdf
For C# need to make these changes to this programm, httppastebin..pdf
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf1- The design of a singly-linked list below is a picture of the functi (1).pdf
1- The design of a singly-linked list below is a picture of the functi (1).pdf
 
In this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdfIn this lab, we will write an application to store a deck of cards i.pdf
In this lab, we will write an application to store a deck of cards i.pdf
 
03. Week 03.pptx
03. Week 03.pptx03. Week 03.pptx
03. Week 03.pptx
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdfIn C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
In C++ please, do not alter node.hStep 1 Inspect the Node.h file.pdf
 
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 Sorted number list implementation with linked listsStep 1 Inspec.pdf Sorted number list implementation with linked listsStep 1 Inspec.pdf
Sorted number list implementation with linked listsStep 1 Inspec.pdf
 
Write a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdfWrite a program that converts an infix expression into an equivalent.pdf
Write a program that converts an infix expression into an equivalent.pdf
 
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbbqueuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
queuesArrays.ppt bbbbbbbbbbbbbbbbbbbbbbbbbb
 
Stata cheatsheet programming
Stata cheatsheet programmingStata cheatsheet programming
Stata cheatsheet programming
 

More from admin463580

Plot total civilian unemployment from 2000 through 2021 adding in the.pdf
Plot total civilian unemployment from 2000 through 2021 adding in the.pdfPlot total civilian unemployment from 2000 through 2021 adding in the.pdf
Plot total civilian unemployment from 2000 through 2021 adding in the.pdf
admin463580
 
Plot the monthly average data presented in Table 1 onto the blank grap.pdf
Plot the monthly average data presented in Table 1 onto the blank grap.pdfPlot the monthly average data presented in Table 1 onto the blank grap.pdf
Plot the monthly average data presented in Table 1 onto the blank grap.pdf
admin463580
 
Please write an SQL query to find the city which have more than 2 ACTI.pdf
Please write an SQL query to find the city which have more than 2 ACTI.pdfPlease write an SQL query to find the city which have more than 2 ACTI.pdf
Please write an SQL query to find the city which have more than 2 ACTI.pdf
admin463580
 
Please use java to write the program that simulates the card game!!! T (1).pdf
Please use java to write the program that simulates the card game!!! T (1).pdfPlease use java to write the program that simulates the card game!!! T (1).pdf
Please use java to write the program that simulates the card game!!! T (1).pdf
admin463580
 
Please use c++ and give screen shot of full code There are n boxes of.pdf
Please use c++ and give screen shot of full code  There are n boxes of.pdfPlease use c++ and give screen shot of full code  There are n boxes of.pdf
Please use c++ and give screen shot of full code There are n boxes of.pdf
admin463580
 
Please use c++ There are n boxes of n different items in a warehouse-.pdf
Please use c++  There are n boxes of n different items in a warehouse-.pdfPlease use c++  There are n boxes of n different items in a warehouse-.pdf
Please use c++ There are n boxes of n different items in a warehouse-.pdf
admin463580
 
please solve the following questions in the picture- Part2 - Based on.pdf
please solve the following questions in the picture- Part2 - Based on.pdfplease solve the following questions in the picture- Part2 - Based on.pdf
please solve the following questions in the picture- Part2 - Based on.pdf
admin463580
 
please solve thank you All of the following statements concerning osmo.pdf
please solve thank you All of the following statements concerning osmo.pdfplease solve thank you All of the following statements concerning osmo.pdf
please solve thank you All of the following statements concerning osmo.pdf
admin463580
 
Please solve the following problem- Create a program that allows disce.pdf
Please solve the following problem- Create a program that allows disce.pdfPlease solve the following problem- Create a program that allows disce.pdf
Please solve the following problem- Create a program that allows disce.pdf
admin463580
 
Please solve Question 9- 8- P the.pdf
Please solve Question 9-  8- P the.pdfPlease solve Question 9-  8- P the.pdf
Please solve Question 9- 8- P the.pdf
admin463580
 
Please show your work! Draw an UML class diagram showing the classes.pdf
Please show your work!   Draw an UML class diagram showing the classes.pdfPlease show your work!   Draw an UML class diagram showing the classes.pdf
Please show your work! Draw an UML class diagram showing the classes.pdf
admin463580
 
Please simply answer the questions below using Internet research (Scho.pdf
Please simply answer the questions below using Internet research (Scho.pdfPlease simply answer the questions below using Internet research (Scho.pdf
Please simply answer the questions below using Internet research (Scho.pdf
admin463580
 
Please solve (b) The frequency distribution of heights of 100 college.pdf
Please solve  (b) The frequency distribution of heights of 100 college.pdfPlease solve  (b) The frequency distribution of heights of 100 college.pdf
Please solve (b) The frequency distribution of heights of 100 college.pdf
admin463580
 
Please show the work for this question- The Voyager spacecraft has bee.pdf
Please show the work for this question- The Voyager spacecraft has bee.pdfPlease show the work for this question- The Voyager spacecraft has bee.pdf
Please show the work for this question- The Voyager spacecraft has bee.pdf
admin463580
 
please show the work to the numerical example i need help The Network.pdf
please show the work to the numerical example i need help The Network.pdfplease show the work to the numerical example i need help The Network.pdf
please show the work to the numerical example i need help The Network.pdf
admin463580
 
Please show that L is regular by creating a DFA- Consider the followin.pdf
Please show that L is regular by creating a DFA- Consider the followin.pdfPlease show that L is regular by creating a DFA- Consider the followin.pdf
Please show that L is regular by creating a DFA- Consider the followin.pdf
admin463580
 
please type all answers asap- i dont have figures- just do it without (1).pdf
please type all answers asap- i dont have figures- just do it without (1).pdfplease type all answers asap- i dont have figures- just do it without (1).pdf
please type all answers asap- i dont have figures- just do it without (1).pdf
admin463580
 
Please trace the execution of the following solution to the Dining Phi.pdf
Please trace the execution of the following solution to the Dining Phi.pdfPlease trace the execution of the following solution to the Dining Phi.pdf
Please trace the execution of the following solution to the Dining Phi.pdf
admin463580
 
please show elegoo arduino board setup using a passive buzzer- heres t.pdf
please show elegoo arduino board setup using a passive buzzer- heres t.pdfplease show elegoo arduino board setup using a passive buzzer- heres t.pdf
please show elegoo arduino board setup using a passive buzzer- heres t.pdf
admin463580
 
Please translate this into MIPS Assembly without using Psuedo-instruct.pdf
Please translate this into MIPS Assembly without using Psuedo-instruct.pdfPlease translate this into MIPS Assembly without using Psuedo-instruct.pdf
Please translate this into MIPS Assembly without using Psuedo-instruct.pdf
admin463580
 

More from admin463580 (20)

Plot total civilian unemployment from 2000 through 2021 adding in the.pdf
Plot total civilian unemployment from 2000 through 2021 adding in the.pdfPlot total civilian unemployment from 2000 through 2021 adding in the.pdf
Plot total civilian unemployment from 2000 through 2021 adding in the.pdf
 
Plot the monthly average data presented in Table 1 onto the blank grap.pdf
Plot the monthly average data presented in Table 1 onto the blank grap.pdfPlot the monthly average data presented in Table 1 onto the blank grap.pdf
Plot the monthly average data presented in Table 1 onto the blank grap.pdf
 
Please write an SQL query to find the city which have more than 2 ACTI.pdf
Please write an SQL query to find the city which have more than 2 ACTI.pdfPlease write an SQL query to find the city which have more than 2 ACTI.pdf
Please write an SQL query to find the city which have more than 2 ACTI.pdf
 
Please use java to write the program that simulates the card game!!! T (1).pdf
Please use java to write the program that simulates the card game!!! T (1).pdfPlease use java to write the program that simulates the card game!!! T (1).pdf
Please use java to write the program that simulates the card game!!! T (1).pdf
 
Please use c++ and give screen shot of full code There are n boxes of.pdf
Please use c++ and give screen shot of full code  There are n boxes of.pdfPlease use c++ and give screen shot of full code  There are n boxes of.pdf
Please use c++ and give screen shot of full code There are n boxes of.pdf
 
Please use c++ There are n boxes of n different items in a warehouse-.pdf
Please use c++  There are n boxes of n different items in a warehouse-.pdfPlease use c++  There are n boxes of n different items in a warehouse-.pdf
Please use c++ There are n boxes of n different items in a warehouse-.pdf
 
please solve the following questions in the picture- Part2 - Based on.pdf
please solve the following questions in the picture- Part2 - Based on.pdfplease solve the following questions in the picture- Part2 - Based on.pdf
please solve the following questions in the picture- Part2 - Based on.pdf
 
please solve thank you All of the following statements concerning osmo.pdf
please solve thank you All of the following statements concerning osmo.pdfplease solve thank you All of the following statements concerning osmo.pdf
please solve thank you All of the following statements concerning osmo.pdf
 
Please solve the following problem- Create a program that allows disce.pdf
Please solve the following problem- Create a program that allows disce.pdfPlease solve the following problem- Create a program that allows disce.pdf
Please solve the following problem- Create a program that allows disce.pdf
 
Please solve Question 9- 8- P the.pdf
Please solve Question 9-  8- P the.pdfPlease solve Question 9-  8- P the.pdf
Please solve Question 9- 8- P the.pdf
 
Please show your work! Draw an UML class diagram showing the classes.pdf
Please show your work!   Draw an UML class diagram showing the classes.pdfPlease show your work!   Draw an UML class diagram showing the classes.pdf
Please show your work! Draw an UML class diagram showing the classes.pdf
 
Please simply answer the questions below using Internet research (Scho.pdf
Please simply answer the questions below using Internet research (Scho.pdfPlease simply answer the questions below using Internet research (Scho.pdf
Please simply answer the questions below using Internet research (Scho.pdf
 
Please solve (b) The frequency distribution of heights of 100 college.pdf
Please solve  (b) The frequency distribution of heights of 100 college.pdfPlease solve  (b) The frequency distribution of heights of 100 college.pdf
Please solve (b) The frequency distribution of heights of 100 college.pdf
 
Please show the work for this question- The Voyager spacecraft has bee.pdf
Please show the work for this question- The Voyager spacecraft has bee.pdfPlease show the work for this question- The Voyager spacecraft has bee.pdf
Please show the work for this question- The Voyager spacecraft has bee.pdf
 
please show the work to the numerical example i need help The Network.pdf
please show the work to the numerical example i need help The Network.pdfplease show the work to the numerical example i need help The Network.pdf
please show the work to the numerical example i need help The Network.pdf
 
Please show that L is regular by creating a DFA- Consider the followin.pdf
Please show that L is regular by creating a DFA- Consider the followin.pdfPlease show that L is regular by creating a DFA- Consider the followin.pdf
Please show that L is regular by creating a DFA- Consider the followin.pdf
 
please type all answers asap- i dont have figures- just do it without (1).pdf
please type all answers asap- i dont have figures- just do it without (1).pdfplease type all answers asap- i dont have figures- just do it without (1).pdf
please type all answers asap- i dont have figures- just do it without (1).pdf
 
Please trace the execution of the following solution to the Dining Phi.pdf
Please trace the execution of the following solution to the Dining Phi.pdfPlease trace the execution of the following solution to the Dining Phi.pdf
Please trace the execution of the following solution to the Dining Phi.pdf
 
please show elegoo arduino board setup using a passive buzzer- heres t.pdf
please show elegoo arduino board setup using a passive buzzer- heres t.pdfplease show elegoo arduino board setup using a passive buzzer- heres t.pdf
please show elegoo arduino board setup using a passive buzzer- heres t.pdf
 
Please translate this into MIPS Assembly without using Psuedo-instruct.pdf
Please translate this into MIPS Assembly without using Psuedo-instruct.pdfPlease translate this into MIPS Assembly without using Psuedo-instruct.pdf
Please translate this into MIPS Assembly without using Psuedo-instruct.pdf
 

Recently uploaded

Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
Celine George
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 

Recently uploaded (20)

Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
How to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRMHow to Manage Your Lost Opportunities in Odoo 17 CRM
How to Manage Your Lost Opportunities in Odoo 17 CRM
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 

Please the following is the currency class of perious one- class Curre.pdf

  • 1. Please the following is the currency class of perious one. class Currency { protected: int whole; int fraction; virtual std::string get_name() = 0; public: Currency() { whole = 0; fraction = 0; } Currency(double value) { if (value < 0) throw "Invalid value"; whole = int(value); fraction = std::round(100 * (value - whole)); } Currency(const Currency& curr) { whole = curr.whole; fraction = curr.fraction; } /* This algorithm gets the whole part or fractional part of the currency Pre: whole, fraction - integer numbers
  • 2. Post: Return: whole or fraction */ int get_whole() { return whole; } int get_fraction() { return fraction; } /* This algorithm adds an object to the same currency Pre: object (same currency) Post: Return: */ void set_whole(int w) { if (w >= 0) whole = w; } void set_fraction(int f) { if (f >= 0 && f < 100) fraction = f; } /* This algorithm adds an object to the same currency Pre: object (same currency) Post: Return: */
  • 3. void add(const Currency* curr) { whole += curr->whole; fraction += curr->fraction; if (fraction > 100) { whole++; fraction %= 100; } } /* This algorithm subtracts an object to the same currency Pre: object (same currency) Post: Return: */ void subtract(const Currency* curr) { if (!isGreater(*curr)) throw "Invalid Subtraction"; whole -= curr->whole; if (fraction < curr->fraction) { fraction = fraction + 100 - curr->fraction; whole--; } else {
  • 4. fraction -= curr->fraction; } } /* This algorithm compares the an object of the same currency for equality or inequality Pre: object (same currency) Post: Return: whole/fraction */ bool isEqual(const Currency& curr) { return curr.whole == whole && curr.fraction == fraction; } /* This algorithm compares the an object of the same currency to determine which is greater or smaller Pre: object (same currency) Post: Return: true/false */ bool isGreater(const Currency& curr) { if (whole < curr.whole) return false; if (whole == curr.whole && fraction < curr.fraction) return false; return true; }
  • 5. /* This algorithm prints the name and value of the currency object Pre: value of whole, fraction, and the name Post: whole, fraction, get_name() Return: */ void print() { std::cout << whole << "." << fraction << " " << get_name() << std::endl; } }; class Krone : public Currency { protected: /* This algorithm gets the name for the Currency. Pre: name - declared as string and initialized as Krone Post: Return: name */ std::string name = "Krone"; std::string get_name() { return name; } public: Krone() : Currency() { }
  • 6. Krone(double value) : Currency(value) { } Krone(Krone& curr) : Currency(curr) { } }; class Soum : public Currency { protected: /* This algorithm gets the name for the Currency. Pre: name - declared as string and initialized as Soum Post: Return: name */ std::string name = "Soum"; std::string get_name() { return name; } public: Soum() : Currency() { } Soum(double value) : Currency(value) { } Soum(Krone& curr) : Currency(curr) { } }; A LinkNode structure or class which will have two attributes - a data attribute, and a pointer attribute to the next node. The data attribute of the LinkNode should be a reference/pointer of the Currency class of Lab 2.
  • 7. Do not make it an inner class or member structure to the SinglyLinkedList class of #2 below. A SinglyLinkedList class which will be composed of three attributes - a count attribute, a LinkNode pointer/reference attribute named as and pointing to the start of the list and a LinkNode pointer/reference attribute named as and pointing to the end of the list. Since this is a class, make sure all these attributes are private. The class and attribute names for the node and linked list are the words in bold in #1 and #2. For the Linked List, implement the following linked-list behaviors as explained in class - getters/setters/constructors/destructors, as needed, for the attributes of the class. createList method in addition to the constructor - this is optional for overloading purposes. destroyList method in place of or in addition to the destructor - this is optional for overloading purposes, addCurrency method which takes a Currency object and a node index value as parameters to add the Currency to the list at that index. removeCurrency method which takes a Currency object as parameter and removes that Currency object from the list and may return a copy of the Currency. removeCurrency overload method which takes a node index as parameter and removes the Currency object at that index and may return a copy of the Currency. findCurrency method which takes a Currency object as parameter and returns the node index at which the Currency is found in the list. getCurrency method which takes an index values as a parameter and returns the Currency object. printList method which returns a string of all the Currency objects in the list in the order of index, tab spaced. isListEmpty method which returns if a list is empty or not. countCurrency method which returns a count of Currency nodes in the list. Any other methods you think would be useful in your program.
  • 8. A Stack class derived from the SinglyLinkedList but with no additional attributes and the usual stack methods - constructor and createStack (optional) methods, push which takes a Currency object as parameter and adds it to the top of the stack. pop which takes no parameter and removes and returns the Currency object from the top of the stack. peek which takes no parameter and returns a copy of the Currency object at the top of the stack. printStack method which returns a string signifying the contents of the stack from the top to bottom, tab spaced. destructor and/or destroyStack (optional) methods. Ensure that the Stack objects do not allow Linked List functions to be used on them. A Queue class derived from the SinglyLinkedList but with no additional attributes and the usual queue methods - constructor and createQueue (optional) methods, enqueue which takes a Currency object as parameter and adds it to the end of the queue. dequeue which takes no parameter and removes and returns the Currency object from the front of the queue. peekFront which takes no parameter and returns a copy of the Currency object at the front of the queue. peekRear which takes no parameter and returns a copy of the Currency object at the end of the queue. printQueue method which returns a string signifying the contents of the queue from front to end, tab spaced. destructor and/or destroyQueue (optional) methods. Ensure that the Queue objects do not allow Linked List functions to be used on them. Ensure that all your classes are mimimal and cohesive with adequate walls around them. Make sure to reuse and not duplicate any code.
  • 9. Then write a main driver program that will demonstrate all the capabilities of your ADTs as follows - First, print a Welcome message for the demonstration of your ADTs - you can decide what the message says but it should include your full name(s). Second, create the following twenty (20) Krone objects in a Currency array to be used in the program. Kr 57.12 Kr 23.44 Kr 87.43 Kr 68.99 Kr 111.22 Kr 44.55 Kr 77.77 Kr 18.36 Kr 543.21 Kr 20.21 Kr 345.67 Kr 36.18 Kr 48.48 Kr 101.00 Kr 11.00 Kr 21.00 Kr 51.00 Kr 1.00 Kr 251.00
  • 10. Kr 151.00 Then, create one each of SinglyLinkedList, Stack and Queue objects. For the linked list, perform the following operations in order - Add the first seven (7) objects from the array into the linked list in order such that they end up in the reverse order in the linked list, i.e. the seventh element as first node and first element as seventh node. If it is easier, you are allowed to insert copies of the objects. Search for Kr 87.43 followed by Kr 44.56 - print the results of each. Remove the node containing Kr 111.22 followed by the node at index 2. Print the contents of the list. Then add the next four (4) objects (#9 thru 12) such that their index in the linked list is calculated as (index in array % 5). Remove two (2) objects at indexes (countCurrency % 6) and (countCurrency / 7) in that order. Print the contents of the list. For the stack, perform the following operations in order - Push seven (7) objects starting from the array index 13 onwards to the stack. Peek the top of the stack - print the result. Perform three (3) pops in succession. Print the contents of the stack. Push five (5) more objects from the start of the objects array to the stack. Pop twice in succession. Print the contents of the stack. For the queue, perform the following operations in order - Enqueue the seven (7) objects at odd indexes starting from index 5 in the array. Peek the front and end of the queue - print the results. Perform two (2) dequeues in succession.
  • 11. Print the contents of the queue. Enqueue five (5) more objects from the index 10 in the array. Dequeue three times in succession. Print the contents of the queue. End the program with a leaving message of your choice. Remember to clean up before the program ends. Restrict all your input / output to the main driver program only, except for the existing screen print inside the Currency print methods.