Tuesday, 5 May 2015

Write a Program In C Plus Plus For Currency Converter

Currency Converter in C++
Problem Description: Write a program in c++ which will convert the pound into its equivalent decimal number and convert it into euro. The program will ask you to enter pounds, shillings and pence and then it will convert in into decimal and Euro.




#include<iostream>
#include<conio.h>
#include<cmath>
using namespace std;


int main()
{
   int pound,shilling,pence;
   char ch;
   do
   {
   cout << "Enter the amounts of pounds,shillings and pence" << endl << endl;
   cout << "Pound(s) : ";
   cin >> pound;
   cout << "Shilling(s) : ";
   cin >> shilling;
   cout << "Pence : ";
   cin >> pence;
   cout << endl;
   
   float tpenny = (static_cast<float>(shilling * 12) + pence)/240;
   float final = (pound) + tpenny;
   
   cout << "In Decimal Pounds" <<'\n'<<'\x9c'<<pound<<"."<<shilling<<"."<<pence<<" = "<<'\x9c'<<final << endl << endl;
   cout << "To end the Program Press 'X or x' and To continue Press any 'Y or y' " << endl;
   cin >> ch;
   }  
   while(ch!='x');
   
   
   system("pause");
   return 0;
   }

0 comments:

Post a Comment