Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 1 Data: (USD) Dollar_Currency.cpp #include Dollar_Currency.h #include #include //Constructor implemented Dollar_currency::Dollar_currency() { this->yen = 0; this->euro = 0; this->num1 = 0; this->num2 = 0;

image text in transcribed

Lab 1 Data:

(USD)

Dollar_Currency.cpp

#include "Dollar_Currency.h"

#include

#include

//Constructor implemented

Dollar_currency::Dollar_currency()

{

this->yen = 0;

this->euro = 0;

this->num1 = "\0";

this->num2 = "\0";

}

//Param constructor

Dollar_currency::Dollar_currency(int yen, int euro)

{

this->yen = yen;

this->euro = euro;

}

void Dollar_currency::setYen(int yen)

{

this->yen = yen;

}

void Dollar_currency::setEuro(int euro)

{

this->euro = euro;

}

void Dollar_currency::setNum1(string num1)

{

this->num1 = num1;

}

void Dollar_currency::setNum2(string num2)

{

this->num2 = num2;

}

double Dollar_currency::getDollar()

{

double value = this->getEuro();

double value1 = 0.01* value;

double ans = (double)this->getEuro() + value1;

return ans;

}

int Dollar_currency::getYen()

{

return this->yen;

}

int Dollar_currency::getEuro()

{

return this->euro;

}

string Dollar_currency::getNum1()

{

int no1 = this->getYen();

int last = no1 % 10;

no1 = no1 / 10;

std::string str1;

if (last == 1)

{

str1 = "One ";

}

else if (last == 2)

{

str1 = "Two ";

}

else if (last == 3)

{

str1 = "Three ";

}

else if (last == 4)

{

str1 = "Four ";

}

else if (last == 5)

{

str1 = "Five";

}

else if (last == 6)

{

str1 = "Six ";

}

else if (last == 7)

{

str1 = "Seven ";

}

else if (last == 8)

{

str1 = "Eight";

}

else if (last == 9)

{

str1 = "Nine ";

}

last = no1 % 100;

std::string str2;

if (last == 1)

{

str2 = "Ten ";

}

else if (last == 2)

{

str2 = "Twenty";

}

else if (last == 3)

{

str2 = "Thirty ";

}

else if (last == 4)

{

str2 = "Forty ";

}

else if (last == 5)

{

str2 = "Fifty";

}

else if (last == 6)

{

str2 = "Sixty";

}

else if (last == 7)

{

str2 = "Seventy ";

}

else if (last == 8)

{

str2 = "Eighty";

}

else if (last == 9)

{

str2 = "ninety";

}

return (str2 +" "+ str1);

}

Dollar_Currency.h

#include

#include

#include

class Dollar_currency

{

//Access specifier

private:

//Data members

int yen, euro;

std::string num1, num2;

public:

Dollar_currency(); //Default Constructor

Dollar_currency(int, int); //Parameterised Cosntructor

double getDollar(); //Method to get USDdollar

int getYen();

int getEuro();

string getNum1();

void setYen(int);

void setEuro(int);

void setNum1(string);

void setNum2(string);

};

(C2D FIles)

Canadian_Dollar.cpp

#include "Canadian_Dollar.h"

#include

#include

//Default Constructor implementation

Canadian_Dollar::Canadian_Dollar()

{

this->dollar = 0.0;

}

//Parameterised Cosntructor implementation

Canadian_Dollar::Canadian_Dollar(int yen,int euro):Dollar_currency(yen,euro)

{

this->dollar=Dollar_currency::getDollar()*1.36;

}

//Copy Constructor implementation

Canadian_Dollar::Canadian_Dollar(Canadian_Dollar & cd)

{

this->dollar = cd.dollar;

}

Canadian_Dollar::~Canadian_Dollar()

{

}

//+ operator overloaded implementation

Canadian_Dollar Canadian_Dollar::operator+(Canadian_Dollar & cd)

{

Canadian_Dollar cd1;

cd1.dollar = this->getDollar() + cd.getDollar();

return cd1;

}

//- operator overloaded implementation

Canadian_Dollar Canadian_Dollar::operator-(Canadian_Dollar & cd)

{

Canadian_Dollar cd1;

cd1.dollar = this->getDollar() - cd.getDollar();

return cd1;

}

double Canadian_Dollar::getDollar()

{

return this->dollar;

}

bool Canadian_Dollar::greaterCurency(Canadian_Dollar cd)

{

if (this->dollar > cd.dollar)

{

return true;

}

else

{

return false;

}

}

Canadian_Dollar.h

#include"Dollar_Currency.cpp"

#include

#include

//Inheriting Dollar_currency

class Canadian_Dollar:public Dollar_currency

{

//Access Specifier

private:

//Data Member

double dollar;

public:

Canadian_Dollar(); //Default Constructor

Canadian_Dollar(int,int); //Parameterised Constructor

Canadian_Dollar(Canadian_Dollar & cd); //Copy Constructor

~Canadian_Dollar(); //Destructor

Canadian_Dollar operator +(Canadian_Dollar & cd); //+ operator overloaded

Canadian_Dollar operator -(Canadian_Dollar & cd); //- operator overloaded

double getDollar();

bool greaterCurency(Canadian_Dollar); //function for comparing two objects

};

Write a program that will sort an array of data using the following guidelines - DO NOT USE VECTORS, COLLECTIONS, SETS or any other data structures from your programming language. 1. Ask the user for the number of elements, not to exceed SORT_MAX_SIZE = 16 (put appropriate input validation) 2. Ask the user for the type of data they will enter - USD or C2D objects from Lab 1. 3. Use your USD and C2D classes from Lab 1 as-is without making any changes. If you do make changes to be able to complete this lab, then there will be a small penalty. 4. Based on the input, create an appropriate array for the data to be entered. 5. Write a helper function called RecurMergeSort such that: o It is a standalone function not part of any class of Lab 1, Takes in the same type of parameters as any standard MergeSort with recursion behavior, i.e. void MergeSort(USD arr[], int size) o Prints out how the array looks every time a recursive step returns back to its caller For objects of both USD and C2D, the MergeSort should be called using USD references/pointers. Do not write a separate MergeSort for C2D arrays. You might need to pass in a third parameter which identifies the array to be printed - this is language dependent. 6. In your main, allow the user to enter data of their own choosing up to their chosen array size, i.e. first ask for the size of the array and then ask whether the array will contain USD or C2D. There is no sample output - you are allowed to provide user interactivity as you see fit but programs will be graded for clarity of interaction. 7. Then sort the array using your sort function of step 5. Take screenshots to be uploaded with the project. 8. In your main, make sure that the output is being written to console as well as an output file at the same time. Do not copy and paste text from your console to create the output file. 9. Ensure input and any other data validations as needed and provide descriptive prompts with emphasis on usability. 10. Upload your classes from Lab 1 and new code files for Lab 3, output file and the screenshots in one zip file. Grading: 30 pts - EXE works from as explained above without needing any code change 35 pts - your Sort function as per instructions (including coding style, documentation) 35 pts - your main demonstrating everything clearly including (including coding style, documentation and interactivity) . Write a program that will sort an array of data using the following guidelines - DO NOT USE VECTORS, COLLECTIONS, SETS or any other data structures from your programming language. 1. Ask the user for the number of elements, not to exceed SORT_MAX_SIZE = 16 (put appropriate input validation) 2. Ask the user for the type of data they will enter - USD or C2D objects from Lab 1. 3. Use your USD and C2D classes from Lab 1 as-is without making any changes. If you do make changes to be able to complete this lab, then there will be a small penalty. 4. Based on the input, create an appropriate array for the data to be entered. 5. Write a helper function called RecurMergeSort such that: o It is a standalone function not part of any class of Lab 1, Takes in the same type of parameters as any standard MergeSort with recursion behavior, i.e. void MergeSort(USD arr[], int size) o Prints out how the array looks every time a recursive step returns back to its caller For objects of both USD and C2D, the MergeSort should be called using USD references/pointers. Do not write a separate MergeSort for C2D arrays. You might need to pass in a third parameter which identifies the array to be printed - this is language dependent. 6. In your main, allow the user to enter data of their own choosing up to their chosen array size, i.e. first ask for the size of the array and then ask whether the array will contain USD or C2D. There is no sample output - you are allowed to provide user interactivity as you see fit but programs will be graded for clarity of interaction. 7. Then sort the array using your sort function of step 5. Take screenshots to be uploaded with the project. 8. In your main, make sure that the output is being written to console as well as an output file at the same time. Do not copy and paste text from your console to create the output file. 9. Ensure input and any other data validations as needed and provide descriptive prompts with emphasis on usability. 10. Upload your classes from Lab 1 and new code files for Lab 3, output file and the screenshots in one zip file. Grading: 30 pts - EXE works from as explained above without needing any code change 35 pts - your Sort function as per instructions (including coding style, documentation) 35 pts - your main demonstrating everything clearly including (including coding style, documentation and interactivity)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Algorithmic Trading Navigating The Digital Frontier

Authors: Alex Thompson

1st Edition

B0CHXR6CXX, 979-8223284987

More Books

Students also viewed these Databases questions

Question

c. What groups were least represented? Why do you think this is so?

Answered: 1 week ago

Question

7. Describe phases of multicultural identity development.

Answered: 1 week ago