All pastes #1264105 Raw Edit

currency

public cpp v1 · immutable
#1264105 ·published 2008-11-22 03:59 UTC
rendered paste body
#include <iostream>#include <iomanip>using namespace std;int main(){	int input;	cout << "Please define your intention.\n";	cout << "'1' for US to Foreign Currency converter.\n";	cout << "'2' for Classical British Pound to Pound Sterling converter.\n";	cout << "'3' for Pound Sterling to Classical British Pound converter.\n";	cin >> input;	if ( input == 1 )		goto usa;	else if ( input == 2 )		goto uk;	else if ( input == 3 )		goto back;	return 0;usa:	double america;	int precision;	cout << "Amount in US dollars: ";	cin >> america;	double pound = america * 1.487;	double franc = america * 0.172;	double deutschemark = america * 0.584;	double yen = america * 0.00955;	cout << "Set the decimal precision: ";	cin >> precision;	cout << fixed << setprecision (precision) << "Amount in British pounds is: " << '\x9c' << pound << endl;	cout << fixed << setprecision (precision) << "Amount in French francs is: F" << franc << endl;	cout << fixed << setprecision (precision) << "Amount in German deutschemarks is: DM" << deutschemark << endl;	cout << fixed << setprecision (precision) << "Amount in Japanese yen is: " << '\x9d' << yen << endl;	return 0;uk:	double pounds;	double shilling;	double pence;	cout << "Enter pounds: ";	cin >> pounds;	cout << "Enter shillings: ";	cin >> shilling;	cout << "Enter pence: ";	cin >> pence;	double dec = ( pence / 240 ) + ( shilling / 20 ) + pounds;	cout << fixed << setprecision (2) << "Decimal pounds = " << '\x9c' << dec << endl;	return 0;back:	float decpounds;	int poundsi;	float decfrac;	int shillingi;	float decpence;	int pencei;	cout << "Enter decimal pounds: ";	cin >> decpounds;	poundsi = static_cast<int>(decpounds);	decfrac = decpounds - poundsi;	decfrac *= 20;	shillingi = static_cast<int>(decfrac);	decpence = decfrac - shillingi;	decpence *= 12;	pencei = static_cast<int>(decpence);	cout << "Equivalent in old notation = " << '\x9c' << poundsi << "." << shillingi << "." << pencei << endl;	return 0;}