64 613
Assignments Done
99,1%
Successfully Done
In September 2018

Answer to Question #33156 in C++ for Ha Na Choi

Question #33156
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.
Expert's answer
#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
";
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions