6. Program that allows the user to enter an amount in dollars, and the displays this value converted to other monetary units.

Chapter 2: 

C++ Programming Basics 

Programming Exercise

Problem # 6:

On a certain day the British pound was equivalent to $1.487 U.S., the French franc was $0.172, the German deutschemark was $0.584, and the Japanese yen was $0.00955. Write a program that allows the user to enter an amount in dollars, and the displays this value converted to these four other monetary units.

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
    double amount, result, pound=1.487, franc=0.172, deutschemark=0.584, yen=0.00955;
    cout<<"Enter an amount in dollars: ";
    cin>>amount;
    result=amount*pound;
    cout<<"Value in pound: "<<result<<endl;
    result=amount*franc;
    cout<<"Value in franc: "<<result<<endl;
    result=amount*deutschemark;
    cout<<"Value in deutschemark: "<<result<<endl;
    result=amount*yen;
    cout<<"Value in yen: "<<result<<endl;
  
    return 0;
}

Let me know in the comment section if you have any question.

Previous Post:
5. Program that allows the user to enter a letter, and then displays either zero or nonzero, depending on whether a lowercase or uppercase letter was entered.

Comments