In: Computer Science
//.h file code:
#include <string>
namespace com::currencyConversion
{
class CashOut
{
private:
int currency_note_value = 0;
int currency_frac_value = 0;
std::wstring Currency_name =
L"";
public:
CashOut(); //super();
CashOut(int currency_note_value,
int currency_fracaVal, const std::wstring ¤cy_name);
//super();
virtual int getcurrency_note_value();
virtual void setcurrency_note_value(int currency_note_value);
virtual int getcurrency_fracaVal();
virtual void setcurrency_fracaVal(int currency_fracaVal);
virtual std::wstring getCurrency_name();
virtual void setCurrency_name(const std::wstring ¤cy_name);
CashOut(const CashOut &d); //super();
};
}
//.cpp file code:
#include "snippet.h"
namespace com::currencyConversion
{
CashOut::CashOut()
{
// TODO Auto-generated constructor
stub
}
CashOut::CashOut(int currency_note_value, int
currency_fracaVal, const std::wstring ¤cy_name)
{
this->currency_note_value =
currency_note_value;
this->currency_frac_value=
currency_fracaVal;
this->Currency_name =
currency_name;
}
int CashOut::getcurrency_note_value()
{
return currency_note_value;
}
void CashOut::setcurrency_note_value(int
currency_note_value)
{
this->currency_note_value =
currency_note_value;
}
int CashOut::getcurrency_fracaVal()
{
return currency_fracaVal;
}
void CashOut::setcurrency_fracaVal(int
currency_fracaVal)
{
this->currency_frac_value=
currency_fracaVal;
}
std::wstring CashOut::getCurrency_name()
{
return Currency_name;
}
void CashOut::setCurrency_name(const std::wstring
¤cy_name)
{
Currency_name =
currency_name;
}
CashOut::CashOut(const CashOut &d)
{
d.currency_note_value =
currency_note_value;
d.currency_frac_value=
currency_fracaVal;
d.Currency_name =
Currency_name;
}
}
---------------------------------------------------
//.h file code:
#include <string>
#include <iostream>
namespace com::currencyConversion
{
class MoreCash: public CashOut
{
public:
const double conversionFactor =
1.36;
private:
int currency_note_value = 0;
int currency_frac_value = 0;
std::wstring Currency_name;
public:
CashOut *CashOut1 = new
CashOut();
CashOut *CashOut2 = new
CashOut();
virtual ~MoreCash()
{
delete
CashOut1;
delete
CashOut2;
}
MoreCash(CashOut *d);
MoreCash(int currency_note_value , int currency_frac_value , const std::wstring ¤cy_name);
MoreCash();
virtual int getcurrency_note_value ();
virtual void setcurrency_note_value (int currency_note_value );
virtual int getcurrency_frac_value ();
virtual void setcurrency_frac_value (int currency_frac_value );
virtual std::wstring getCurrency_name();
virtual void setCurrency_name(const std::wstring ¤cy_name);
// Methods to Calculate the Total currency amount
virtual double
getConversionFactor();
virtual void AddCurrency();
virtual void SubsCurrency();
virtual void CashOutCurrencyEquality();
virtual void CheckGreaterAmount();
};
}
//.cpp file code:
#include "snippet.h"
namespace com::currencyConversion
{
MoreCash::MoreCash(CashOut *d) : CashOut(d)
{
// TODO Auto-generated constructor
stub
}
MoreCash::MoreCash(int currency_note_value , int
currency_frac_value , const std::wstring ¤cy_name) :
CashOut(currency_note_value , currency_frac_value ,
currency_name)
{
// TODO Auto-generated constructor
stub
}
MoreCash::MoreCash() : CashOut()
{
this->currency_note_value =
currency_note_value ;
this->currency_frac_value =
currency_frac_value ;
Currency_name =
Currency_name;
}
int MoreCash::getcurrency_note_value ()
{
return currency_note_value ;
}
void MoreCash::setcurrency_note_value (int
currency_note_value )
{
this->currency_note_value =
currency_note_value ;
}
int MoreCash::getcurrency_frac_value ()
{
return currency_frac_value ;
}
void MoreCash::setcurrency_frac_value (int
currency_frac_value )
{
this->currency_frac_value =
currency_frac_value ;
}
std::wstring MoreCash::getCurrency_name()
{
return Currency_name;
}
void MoreCash::setCurrency_name(const std::wstring
¤cy_name)
{
Currency_name =
currency_name;
}
double MoreCash::getConversionFactor()
{
return conversionFactor;
}
void MoreCash::AddCurrency()
{
std::wcout << L"Enter the
First ( currency_note_value Amount) of the Currency" <<
std::endl;
CashOut1->setcurrency_note_value
(sc::nextInt());
std::wcout << L"Enter the
First (currency_frac_value Amount) of the Currency" <<
std::endl;
CashOut1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second (currency_note_value Amount) of the Currency" <<
std::endl;
CashOut2->setcurrency_note_value
(sc::nextInt());
std::wcout << L"Enter the
Second (currency_frac_value Amount) of the Currency" <<
std::endl;
CashOut2->setcurrency_frac_value
(sc::nextInt());
double usdCurrency1;
usdCurrency1 =
CashOut1->getcurrency_note_value () +
CashOut1->getcurrency_frac_value () / 100;
double usdCurrrency2;
usdCurrrency2 =
CashOut2->getcurrency_note_value () +
CashOut2->getcurrency_frac_value () / 100;
double totalUsd = usdCurrency1 +
usdCurrrency2;
std::wcout << totalUsd
<< std::endl;
}
void MoreCash::SubsCurrency()
{
std::wcout << L"Enter the
First ( currency_note_value Amount) of the Currency" <<
std::endl;
cin>>
CashOut1->setcurrency_note_value
(put);
std::wcout << L"Enter the
First (currency_frac_value Amount) of the Currency" <<
std::endl;
CashOut1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second (currency_note_value Amount) of the Currency" <<
std::endl;
CashOut2->setcurrency_note_value
(sc::nextInt());
std::wcout << L"Enter the
Second (currency_frac_value Amount) of the Currency" <<
std::endl;
CashOut2->setcurrency_frac_value
(sc::nextInt());
double usdCurrency1;
usdCurrency1 =
CashOut1->getcurrency_note_value () +
CashOut1->getcurrency_frac_value () / 100;
double usdCurrrency2;
usdCurrrency2 =
CashOut2->getcurrency_note_value () +
CashOut2->getcurrency_frac_value () / 100;
double totalUsd = usdCurrency1 -
usdCurrrency2;
if (totalUsd > 0)
{
std::wcout
<< totalUsd << std::endl;
}
else
{
std::wcout
<< -totalUsd << std::endl;
}
}
void MoreCash::CashOutCurrencyEquality()
{
std::wcout << L"Enter the
First ( currency_note_value Amount) of the Currency" <<
std::endl;
cin>>currency_note_value ;
CashOut1->setcurrency_note_value
(cin>>currency_note_value));
std::wcout << L"Enter the
First (currency_frac_value Amount) of the Currency" <<
std::endl;
CashOut1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second (currency_note_value Amount) of the Currency" <<
std::endl;
CashOut2->setcurrency_note_value
(sc::nextInt());
std::wcout << L"Enter the
Second (currency_frac_value Amount) of the Currency" <<
std::endl;
CashOut2->setcurrency_frac_value
(sc::nextInt());
std::wstring equal = L" Equal",
unequal = L"Unequal";
double usdCurrency1;
usdCurrency1 =
CashOut1->getcurrency_note_value () +
CashOut1->getcurrency_frac_value () / 100;
double usdCurrrency2;
usdCurrrency2 =
CashOut2->getcurrency_note_value () +
CashOut2->getcurrency_frac_value () / 100;
double totalUsd = usdCurrency1 +
usdCurrrency2;
if (usdCurrency1 ==
usdCurrrency2)
{
std::wcout
<< equal << std::endl;
}
else
{
std::wcout
<< unequal << std::endl;
}
}
void MoreCash::CheckGreaterAmount()
{
std::wcout << L"Enter the
First ( currency_note_value Amount) of the Currency" <<
std::endl;
CashOut1->setcurrency_note_value
(sc::nextInt());
std::wcout << L"Enter the
First (currency_frac_value Amount) of the Currency" <<
std::endl;
CashOut1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second (currency_note_value Amount) of the Currency" <<
std::endl;
CashOut2->setcurrency_note_value
(sc::nextInt());
std::wcout << L"Enter the
Second (currency_frac_value Amount) of the Currency" <<
std::endl;
CashOut2->setcurrency_frac_value
(sc::nextInt());
double usdCurrency1;
usdCurrency1 =
CashOut1->getcurrency_note_value () +
CashOut1->getcurrency_frac_value () / 100;
double usdCurrrency2;
usdCurrrency2 =
CashOut2->getcurrency_note_value () +
CashOut2->getcurrency_frac_value () / 100;
double totalUsd = usdCurrency1 +
usdCurrrency2;
if (usdCurrency1 >
usdCurrrency2)
{
std::wcout
<< L" Greater Currency1: " << usdCurrency1 <<
std::endl;
}
else
{
std::wcout
<< L" Greater Currency1: " << usdCurrrency2 <<
std::endl;
}
}
}
-----------------------------------------
//.h file code:
#include <iostream>
namespace com::currencyConversion
{
using namespace com::currencyConversion;
class Bag : public CIS22C_CashOut1
{
public:
CashOut *d1 = new CashOut(15, 16,
L"USD");
CIS22C_CashOut1 *d2 = new
CIS22C_CashOut1(17, 18, L"C2D");
virtual ~Bag()
{
delete d1;
delete d2;
}
virtual double USDCurrency();
virtual double C2DCurrency();
double getConversionFactor() override;
void AddCurrency() override;
void SubsCurrency() override;
void CashOutCurrencyEquality() override;
void CheckGreaterAmount() override;
};
}
//.cpp file code:
#include "snippet.h"
namespace com::currencyConversion
{
using namespace com::currencyConversion;
double Bag::USDCurrency()
{
double usdCurrency;
usdCurrency =
d1->getcurrency_note_value () + d1->getcurrency_frac_value ()
/ 100;
return usdCurrency;
}
double Bag::C2DCurrency()
{
double c2dCurrency;
c2dCurrency =
d2->getcurrency_note_value () + d2->getcurrency_frac_value ()
/ 1000;
return c2dCurrency;
}
double Bag::getConversionFactor()
{
return
CIS22C_CashOut1::getConversionFactor();
}
void Bag::AddCurrency()
{
std::wcout << L"Enter the
First currency_note_value Amount of the Currency" <<
std::endl;
d1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
First currency_frac_value Amount of the Currency" <<
std::endl;
d1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second currency_note_value Amount of the Currency" <<
std::endl;
CashOut2::setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second currency_frac_value Amount of the Currency" <<
std::endl;
CashOut2::setcurrency_frac_value
(sc::nextInt());
double usdCurrency1;
usdCurrency1 =
d1->getcurrency_note_value () + d1->getcurrency_frac_value ()
/ 100;
double c2dCurrrency2;
c2dCurrrency2 =
d2->getcurrency_note_value () + d2->getcurrency_frac_value ()
/ 1000;
std::wcout <<
(usdCurrency1 + c2dCurrrency2 * getConversionFactor()) <<
std::endl;
}
void Bag::SubsCurrency()
{
std::wcout << L"Enter the
First currency_note_value Amount of the Currency" <<
std::endl;
d1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
First currency_frac_value Amount of the Currency" <<
std::endl;
d1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second currency_note_value Amount of the Currency" <<
std::endl;
d2->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second currency_frac_value Amount of the Currency" <<
std::endl;
d2->setcurrency_frac_value
(sc::nextInt());
double usdCurrency1;
usdCurrency1 =
d1->getcurrency_note_value () + d1->getcurrency_frac_value ()
/ 100;
double c2dCurrrency2;
c2dCurrrency2 =
d2->getcurrency_note_value () + d2->getcurrency_frac_value ()
/ 1000;
std::wcout << (usdCurrency1 - c2dCurrrency2 * getConversionFactor()) << std::endl;
}
void Bag::CashOutCurrencyEquality()
{
std::wcout << L"Enter the
First currency_note_value Amount of the Currency" <<
std::endl;
d1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
First currency_frac_value Amount of the Currency" <<
std::endl;
d1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second currency_note_value Amount of the Currency" <<
std::endl;
d2->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second currency_frac_value Amount of the Currency" <<
std::endl;
d2->setcurrency_frac_value
(sc::nextInt());
double usdCurrency1;
usdCurrency1 =
d1->getcurrency_note_value () + d1->getcurrency_frac_value ()
/ 100;
double c2dCurrrency2;
c2dCurrrency2 =
d2->getcurrency_note_value () + d2->getcurrency_frac_value ()
/ 1000;
if ((usdCurrency1) ==
c2dCurrrency2 * getConversionFactor())
{
std::wcout
<< L"Currency Value Are Equal" << std::endl;
}
else
{
std::wcout
<< L"The Currency Value is Unequal" << std::endl;
}
}
void Bag::CheckGreaterAmount()
{
std::wcout << L"Enter the
First currency_note_value Amount of the Currency" <<
std::endl;
d1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
First currency_frac_value Amount of the Currency" <<
std::endl;
d1->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second currency_note_value Amount of the Currency" <<
std::endl;
d2->setcurrency_frac_value
(sc::nextInt());
std::wcout << L"Enter the
Second currency_frac_value Amount of the Currency" <<
std::endl;
d2->setcurrency_frac_value
(sc::nextInt());
double usdCurrency1;
usdCurrency1 =
d1->getcurrency_note_value () + d1->getcurrency_frac_value ()
/ 100;
double c2dCurrrency2;
c2dCurrrency2 =
d2->getcurrency_note_value () + d2->getcurrency_frac_value ()
/ 1000;
if (usdCurrency1 >
c2dCurrrency2 * getConversionFactor())
{
std::wcout
<< L"The USD Currency is Greater" << std::endl;
}
else
{
std::wcout
<< L"The C2D Currency is Greater" << std::endl;
}
}
}
//.h file code:
#include <string>
#include <vector>
#include <iostream>
#include <any>
namespace com::currencyConversion
{
class Main_Test
{
public:
static void
main(std::vector<std::wstring> &args);
};
}
#include <string>
#include <vector>
int main(int argc, char **argv)
{
std::vector<std::wstring> args(argv + 1, argv + argc);
com::currencyConversion::Main_Test::main(args);
}
//.cpp file code:
#include "snippet.h"
namespace com::currencyConversion
{
void
Main_Test::main(std::vector<std::wstring> &args)
{
Scanner *scan = new
Scanner(System::in);
Wallet *wal = new Wallet();
CIS22C_CashOut1 *CashOut = new
CIS22C_CashOut1();
std::wcout << L" Choose the
Number as perform Operation to Perform " << std::endl;
std::wcout << L" Press -- 1
-- to Add same Type oF Currency " << std::endl;
std::wcout << L" Press -- 2
-- to substract same Type oF Currency " << std::endl;
std::wcout << L" Press -- 3
-- to FindGreater same Type oF Currency " << std::endl;
std::wcout << L" press -- 4
-- to Compare same Type oF Currency " << std::endl;
std::wcout << L" Press -- 5
-- to Add Different Type oF Currency " << std::endl;
std::wcout << L" Press -- 6
-- to substract Different Type oF Currency " <<
std::endl;
std::wcout << L" Press -- 7
-- to FindGreater Different Type oF Currency" <<
std::endl;
std::wcout << L" press -- 8
-- to Compare Different Type oF Currency " <<
std::endl;
std::wcout << L" Press -- 9
-- to exit" << std::endl;
int num1 = 0;
while (num1 != 9)
{
num1 =
scan->nextInt();
switch
(num1)
{
case 1:
CashOut->AddCurrency();
break;
case 2:
CashOut->SubsCurrency();
break;
case 3:
CashOut->CheckGreaterAmount();
break;
case 4:
CashOut->CheckCurrencyEquality();
break;
case 5:
wal->AddCurrency();
break;
case 6:
wal->SubsCurrency();
break;
case 7:
wal->CheckGreaterAmount();
break;
case 8:
wal->CheckCurrencyEquality();
break;
case 9:
break;
}
}
delete CashOut;
delete wal;
delete scan;
}
}
Kindly...Excuse for Some typo errors ( converted from java to c++)