Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program (with c only) to implement a simple currency converter program.

ID: 3783777 • Letter: W

Question

Write a program (with c only) to implement a simple currency converter program. Commands are as follows:

Euro-US

US-Euro

Euro-Pound

Pound-Euro

Pound-US

US-Pound

showrates

quit

Note that the commands are EXACTLY as shown. Capital letters and lower case letters as shown. There is a very good reason for this requirement, as will become clear later in the semester.

Commands work as follows:

Euro-US

requests a currency amount in Euros

converts that into a currency amount in $US.

US-Euro

reverse the above; request an amount in $US, convert it into Euros

Euro-Pound, Pound-Euro

same thing for converting Pound Sterling to Euros and vice versa

Pound-US, US-Pound

same thing for converting Pound Sterling to $US and vice versa

showrates

shows the exchange rates used in an appropriate way

quit

exit the program

Use the following currency exchange rates (taken from Monday, August 26, 2013)

$1.0000 US = 0.74759 Euro

$1.0000 US = 0.64173 Pound Sterling

Explanation / Answer

Following code will give you the desired functionality:

//rate conversion
#include<stdio.h>
#include<stdlib.h>

//prototype declaration

int main()
{
int menu;
float dollar, euro, pound;
printf("Choose among the following commands ");
printf("1. Euro-US ");
printf("2. US-Euro ");
printf("3. Euro-Pound ");
printf("4. Pound-Euro ");
printf("5. Pound-US ");
printf("6. US-Pound ");
printf("7. show rates ");
printf("8. quit ");
scanf("%d",&menu);
switch(menu)
{
case 1:
printf("Enter amount in Euro: ");
scanf("%f",&euro);
dollar =(1/0.74759) * euro;
printf("%f Euro will be equal to %f Dollars ",euro,dollar);
break;
case 2:
printf("Enter amount in Dollars: ");
scanf("%f",&dollar);
euro = 0.74759 * dollar;
printf("%f Dollars will be equal to %f Euro ",dollar,euro);
break;
case 3:
printf("Enter amount in Euro: ");
scanf("%f",&euro);
pound = 0.85839 *euro;
printf("%f Euro will be equal to %f Pound Sterling ",euro,pound);
break;
case 4:
printf("Enter amount in Pound Sterling: ");
scanf("%f",&pound);
euro = 1.16496 *pound;
printf("%f Pound Sterling will be equal to %f Euro ",pound,euro);
break;
case 5:
printf("Enter amount in Dollars: ");
scanf("%f",&dollar);
pound = 0.64173 * dollar;
printf("%f Dollars will be equal to %f Pound Sterling ",dollar,pound);
break;
case 6:
printf("Enter amount in Pounds: ");
scanf("%f",&pound);
dollar = 1.55828 *pound;
printf("%f Pounds will be equal to %f Dollars ",pound,dollar);
break;
case 7:
printf("$1 US = 0.74759 Euro ");
printf("1 Euro = $1.3376 US ");
printf("1 Euro = 0.85839 Pound Sterling ");
printf("1 Pound Sterling = 1.16496 Euro ");
printf("$1 US = 0.64173 Pound Sterling ");
printf("1 Pound Sterling = $1.55828 US ");
break;
case 8:
exit(1);
default:
printf("Wrong choice ");
}//end of switch case
return 0;
}//end of main function

Hope it helps. Do comment your feedback. Thanks.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote