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

Write a program to convert currencies between British currency of pounds and pen

ID: 3788565 • Letter: W

Question

Write a program to convert currencies between British currency of pounds and pence, in which 1 pound contains 100 pence, and U.S. currency in dollars and cents. Assume an exchange rate of 1.45 U.S. dollars per British pound. Display a menu like the following:

Convert from British currency to U.S. currency

Convert from U.S. currency to British currency

Exit

When the user chooses 1, prompt the user to enter two numbers representing British pounds and pence, converts to an equivalent number of U.S. dollars and cents, and output the result.

When the user chooses 2, prompt the use to enter two numbers representing U.S. dollars and cents, converts to an equivalent number of British pounds and pence, and output the result.

When the user chooses 3, terminate the program. Program should continue until the user picks 3.

Hint:

Represent British Pounds and pence in total pence, then multiply by 1.45, cast the result as integer, divide by 100 to get dollar amount, modular 100 to get cent amount

Difference is you need to divide by 1.45

The new program has to be changed from the existing conversion program!!

using System public class Convert FromMetric 7 public static void Metric ToEnglish() const double yards PerMeter 9144 double meters IO.GetDouble ("Enter the number of meters to convert 10 double toYards meters yards PerMeter; 11 meters converted to yards 12 int yards (int)toYards 13 integer part of to Yards 14 double excessYards toYards yards 15 fractional part of toYards 16 double toFeet 3 excess Yards 17 excess Yards converted to feet 18 int to Feet feet integer part of toFeet 19 double excess Feet to Feet feet 20 fractional part of toFeet 21 float toInches a (float) (12 excess Feet) 22 excessFeet converted to inches String output Concatenate output for message dialog 24 if (meters 1) output meters meter converts to 26 output +3 meters meters convert to 27 28 output if (yards 0) 29 if yards 1) output yards yard 30 else output yards yards 31 if (feet 0) 32 if (feet 1) output feet foot 34 else output teet teet if (to Inches 0) if (toInches 1) output to Inches inch else output to Inches inches if (yards 0 && feet 0 && toInches 0) 38 output 0 yards 39 Console.WriteLine(output); 40 else

Explanation / Answer

/*add private variable money and methods to existing class I have provided in the below program,also calling the methods from main*/

#include<iostream>
using namespace std;
class converFromMatrix
{
   double money;
public:
   converFromMatrix()
   {
       money = 0;
   }
   void Convert_from_British(int i, int f)
   {
       double m = (double)(i * 100 + f) / 100;
       money = m *1.45;
   }
   void Convert_from_US(int i, int f)
   {
       double m =(double)(i * 100 + f) / 100;
       money =(double) m /1.45;
   }
   double get_converted_money()
   {
      
       return money;
   }
  
};
int main()
{
   int choice;
   double m;
   converFromMatrix obj;
   cout << "Enter 1.Convert_from_British 2.Convert_from_US 0.Exit " << endl;
   do
   {
       cout << "Choice : ";
       cin >> choice;
       if (choice == 1)
       {
           //Convert_from_British
           int pound, pence;
           cout << "Enter pound and pence : ";
           cin>> pound >> pence;
           obj.Convert_from_British(pound,pence);
           cout << "$" << obj.get_converted_money() << endl;
       }
       if (choice == 2)
       {
           //Convert_from_US
           int dollar, cents;
           cout << "Enter dollar and cents : ";
               cin>> dollar >> cents;
           obj.Convert_from_US(dollar,cents);
           cout << "£" << obj.get_converted_money() << endl;
       }
      
   } while (choice != 0); //choice 0 break from while

   return 0;
}

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

//output

Enter 1.Convert_from_British 2.Convert_from_US 0.Exit
Choice : 1
Enter pound and pence : 5 89
$8.5405
Choice : 2
Enter dollar and cents : 8 54
£5.88966
Choice : 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