Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class named KWD which should make use of the money class, implemented in

ID: 3868707 • Letter: W

Question

Write a class named KWD which should make use of the money class, implemented in Sub Problem a, to decompose a given sum of money into an equivalent number of bank note units that are available in the KWD currency.

The KWD class should have the following data member:
sum: double
and it should have the following member functions:
set_sum(s: double): void for setting the value of the sum to be converted/decomposed into bank notes equivalent
get_sum(): double for getting the value of the sum to be converted/decomposed into bank notes equivalent
convert(): void for converting/decomposing the sum into bank notes equivalent.
(this member function can make use of the money class member functions)
display_notes(): void for displaying the decomposed sum in the number of bank notes and the change.

correct the below code and run/display it in C++

#include

#include

using namespace std;

int money;

class KWD

{

double sum;

public:

void set_sum(double s)

{

sum = s;

}

double get_sum()

{

return sum;

}

void convert()

{

money =u;

u.set_money(sum, "KWD", 20);

u.display(20);

sum = u.change();

u.set_money(sum, "KWD", 10);

u.display(10);

sum = u.change();

u.set_money(sum, "KWD", 5);

u.display(5);

sum = u.change();

u.set_money(sum, "KWD", 1);

u.display(1);

sum = u.change();

u.set_money(sum, "KWD", 0.5);

u.display(0.5);

sum = u.change();

u.set_money(sum, "KWD", 0.25);

u.display(0.25);

sum = u.change();

// display the change

cout << endl << "CHANGE = " << u.change() * 1000 << " Fils" << endl;

}

void display_notes()

{

cout << "The equivalent of " << get_sum() << " KWD in bank notes is: " << endl

<< endl;

convert();

cout << endl;

}

};

int main()

{

  

KWD c;

c.set_sum(57.895);

c.display_notes();

return 0;

}

Explanation / Answer

#include

#include

using namespace std;

int money;

class KWD

{

double sum;

public:

void set_sum(double s)

{

sum = s;

}

double get_sum()

{

return sum;

}

void convert()

{

money =u;

u.set_money(sum, "KWD", 20);

u.display(20);

sum = u.change();

u.set_money(sum, "KWD", 10);

u.display(10);

sum = u.change();

u.set_money(sum, "KWD", 5);

u.display(5);

sum = u.change();

u.set_money(sum, "KWD", 1);

u.display(1);

sum = u.change();

u.set_money(sum, "KWD", 0.5);

u.display(0.5);

sum = u.change();

u.set_money(sum, "KWD", 0.25);

u.display(0.25);

sum = u.change();

cout << endl << "CHANGE = " << u.change() * 1000 << " Fils" << endl;

}

void display_notes()

{

cout << "The equivalent of " << get_sum() << " KWD in bank notes is: " << endl

<< endl;

convert();

cout << endl;

}

};

int main()

{

KWD c;

c.set_sum(57.895);

c.display_notes();

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote