Question
Use Constructors, Parameters, and arguments as needed. Create a program in C++ that can convert $dollars to Yen, Euro, or Peso. The user will input
Use Constructors, Parameters, and arguments as needed.
Create a program in C++ that can convert $dollars to Yen, Euro, or Peso.
The user will input a dollar value. If the $dollar value is greater than 0, create a menu that will allow user to select Yen, Euro, Peso, or all Currency conversion. If the $dollar value is less than 0 prompt the user and stop the program.
Write a program that has 4 methods that will return the concurrency conversions for the following.
Yen, Euro, Peso conversion program using a class structure.
Create 4 Methods: use set and get if possible
1) Convert and output conversion in Yen
2) Convert and output conversion in Euro
3) Convert and output conversion in Peso
4) Convert and output all 3 currencies.
here is my program
#include
class CurrencyConverter { public: double value; CurrencyConverter(double value) { this->value = value; } double convertToYen() { return 109.50 * value; } double convertToEuro() { return 0.87 * value; } double convertToPeso() { return 19.10 * value; } void getAlLCurrency() { cout << "The Currency is Yen is" << 109.50 * value << endl; cout << "The Currency is Euro is" << 0.87 * value << endl; cout << "The Currency is Peso is" << 19.10 * value << endl; } }; int main() { int option; double dollar; //output menu cout << "Enter the dollar amount you want to convert" << endl; cin >> dollar; CurrencyConverter convert(dollar); if (dollar <= 0) cout << "The dollar you have entered is invalid" << endl; else {
do { cout << " Here are the options of currencies" << endl; cout << "1.Yen" << endl; cout << "2.Euro" << endl; cout << "3.Peso" << endl; cout << "4. Convert to all" << endl; cout << "5.Quit the program" << endl; cout << "Choose one option :" << endl; cin >> option; switch (option) { case 1: cout << dollar << " dollars is equal to " << convert.convertToYen() << " Yens"; break; case 2:
cout << dollar << " dollars is equal to " << convert.convertToEuro() << " Euros"; break; case 3: cout << dollar << " dollars is equal to " << convert.convertToPeso() << " Pesos"; break; case 4: convert.getAlLCurrency(); break; case 5: cout << "You chose to quit the Program" << endl; break; default: cout << "Invalid Input" << endl; break; }
} while (option != 5); } return 0; }
how to make this program memory efficient
can someone make changes this code to make it memory efficient and comment what is changes. C++ ASAP
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started