Write a program to convert currency from UK pounds or sterling to US dollar. Read the quantity of money in pounds and pence, and output the resulting foreign currency in dollars and cents. (One pound is 100 penny). Use a const to represent the conversion rate, which is $2.018 to £1 currently. Be sure to print suitable headings and or labels for the values to be output.
1
Expert's answer
2013-07-16T08:54:56-0400
#include <iostream> #include <cmath> using namespace std;
const double rate = 2.018;
int main() { int pounds, pence; cout << "Enter the amount of pound: "; cin >> pounds; cout << "Enter the amount of pence: "; cin >> pence; cout << pounds << " punds " << pence << " pence = "; pence = pounds*100 + pence; int cents = round(pence * rate); cout << cents/100 << " dollars "; cout << cents-cents/100*100 << " cents "; }
Comments
Leave a comment