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

Problem Statement: Exchange of currency rates You are required to write a progra

ID: 3619445 • Letter: P

Question

Problem Statement: Exchange of currency rates

You are required to write a program for Currency Exchange rates. The basic idea is that user/reader will be able to interchange different currencies using our program. User will have three options i.e. Pakistani Rupees, US Dollars, and Euro.

Detailed Description:

1. The program should display

Please select currencies that you want to exchange.

Description:

       Enter ‘R’ for Pakistani Rupees.

        Enter ‘E’ for Euro.

        Enter ‘D’ for Dollar.

       

Then your program should take these inputs,

2. Depending upon the choices that user has entered, your program will further display the prompt

3. Then the program should take two inputs from the user as:

      -----------------------------------------------------------------

          Please select the currency that you want to convert :            

          Please select the currency that you want to convert into:

       -----------------------------------------------------------------

4. After getting both inputs, program will calculate the currency rates on the basis on this information.

   1 Euro = 112 Rupees.

   1 Dollar = 84 Rupees.

   1 Euro = 1.33 Dollars

   1 Dollar = 0.75 EUR

After calculating the conversion rate for the selected currencies display it on the screen.

In the end of the program, user should be asked if he/she wants to make another conversion.

If user presses y then the whole program should start again. If user presses n then the program should terminate.

         

Sample Output

Dev c++ Output:

Please select currencies that you want to exchange.

Description:

        Enter ‘R’ for Pakistani Rupees.

        Enter ‘E’ for Euro.

           Enter ‘D’ for Dollar.

    Please select the currency that you want to convert : E         

    Please select the currency that you want to convert into: D

Please enter the amount in Euro : 12

12 Euro = 16 Dollars

Do you want to make another conversion? (y/n) : y

Please select currencies that you want to exchange.

Description:

       Enter ‘R’ for Pakistani Rupees.

       Enter ‘E’ for Euro.

          Enter ‘D’ for Dollar.

   Please select the currency that you want to convert : R         

   Please select the currency that you want to convert into: D

   Please enter the amount in Rupees : 90

  90 Rupees = 1.07143 Dollars

   Do you want to make another conversion? (y/n) : n

    

Hints:

Dev c++ Output:

Please select currencies that you want to exchange.

Description:

        Enter ‘R’ for Pakistani Rupees.

        Enter ‘E’ for Euro.

           Enter ‘D’ for Dollar.

    Please select the currency that you want to convert : E         

    Please select the currency that you want to convert into: D

Please enter the amount in Euro : 12

12 Euro = 16 Dollars

Do you want to make another conversion? (y/n) : y

Please select currencies that you want to exchange.

Description:

       Enter ‘R’ for Pakistani Rupees.

       Enter ‘E’ for Euro.

          Enter ‘D’ for Dollar.

   Please select the currency that you want to convert : R         

   Please select the currency that you want to convert into: D

   Please enter the amount in Rupees : 90

  90 Rupees = 1.07143 Dollars

   Do you want to make another conversion? (y/n) : n

    

Explanation / Answer

 #include <iostream.h>
#include <conio.h>

main()
{

char input1, input2, choice;
float amount, result; //result variable will contain the result of conversion.
choice = 'y'; //This variable is for taking users choice if user wants to repeat the whole program or not
//choice variable is initialized with 'y' therefore the program will enter the loop for the first time

while (choice == 'y' || choice == 'Y') //The loop repeats itself till user enter y or Y in choice variable
{
system("cls"); //clearing the screen
cout << "Please select currencies that you want to exchange." << endl;
cout << "Description:" <<endl;
cout << " Enter 'R' for Pakistani rupees." << endl;
cout << " Enter 'E' for Euro." << endl;
cout << " Enter 'D' for Dollar." << endl;


//Taking input from the user i.e. both currencies
cout << endl;
cout<< "Enter the currency that you want to convert : ";
cin >> input1;
cout<< "Enter the currency that you want to convert : ";
cin >> input2;

cout <<endl;


/*Checking that if user wants to convert rupees into dollars i.e currency to be converted is
rupees and to convert into dollars*/
if(input1 == 'R' && input2 == 'D')
{
cout << "Please enter amount in Rupees : ";
cin >> amount;
result = amount / 84;
cout << endl << amount << " Rupees = " <<result << " Dollars";
}


/*Checking that if user wants to convert rupees into Euro i.e currency to be converted is
rupees and to convert into Euro*/
if(input1 == 'R' && input2 == 'E')
{
cout << "Please enter amount in Rupees : ";
cin >> amount;
result = amount / 112;
cout << endl << amount << " Rupees = " <<result << " Euros";
}

/*Checking that if user wants to convert dollars into rupees i.e currency to be converted is
dollars and to convert into rupees*/
if(input1 == 'D' && input2 == 'R')
{
cout << "Please enter amount in Dollars : ";
cin >> amount;
result = amount * 84;
cout << endl << amount << " Dollars = " <<result << " Rupees";
}

/*Checking that if user wants to convert dollars into Euro i.e currency to be converted is
dollars and to convert into Euro*/
if(input1 == 'D' && input2 == 'E')
{
cout << "Please enter amount in Dollars : ";
cin >> amount;
result = amount / 1.33;
cout << endl << amount << " Dollars = " <<result << " Euros";
}

/*Checking that if user wants to convert dollars into rupees i.e currency to be converted is
euro and to convert into rupees*/
if(input1 == 'E' && input2 == 'R')
{
cout << "Please enter amount in Euro : ";
cin >> amount;
result = amount * 112;
cout << endl << amount << " Euros = " <<result << " Rupees";
}

/*Checking that if user wants to convert Euro into dollars i.e currency to be converted is
Euro and to convert into dollars*/
if(input1 == 'E' && input2 == 'D')
{
cout << "Please enter amount in Euro : ";
cin >> amount;
result = amount * 1.33;
cout << endl << amount << " Euros = " <<result << " Dollars";
}


/*in the end of all if statements, variable result will contain the value from the if statement
which was true for both inputs */

/*Promting user to enter his/her choice whether he/she wants to do another conversion or not*/
cout << endl <<endl << "Do you want to make another conversion (y/n) : ";
cin >> choice; //if user enters y or Y, the condition in the while loop becomes true and the statements in loop body are executed again

}

getch();
}
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