Click to See Complete Forum and Search --> : ArrayConvertingCurrency


chuckwalg
May 16th, 1999, 10:39 AM
Beginning C++ student needing help with code and logic on this one. Any skilled C++ programmer that has 20 minutes to devote to this one?
- Thanks, Chuck chuckwalg@prodigy.net (213)383-7657
... the problem is to allow user to select a currency to convert from, then select a currency to convert to. Ask user how many monetary units to convert and display all the user-selected info as well as display the conversion figures... the logic has me stumped.

/* Workshop 5 - Programming Concepts - Currency Conversion -Chuck Walgenbach */
/* Dated 5/9/99 */

#include<stdio.h>
#include<conio.h> //Enables the use of the clrscr() function.
#define CURRMAX 5 //Maximum number of 5 currencies.
#define MAX 20 //Maximum number of 20 characters.
#define USD 1.00 //Use the U.S. dollar as the standard.
#define DRACHMA .0035 //Exchange rate for Greek Drachma.
#define DMARK .5487 //Exch rate for German Marks.
#define POUND 1.6259 //Exch rate for English Pounds.
#define GUILDER .4867 //Exch rate for Dutch Guilders.

int main(void)

{

char fromCurr,toCurr;
int i;
float convertFrom[5],convertTo[5],units;
float currList[CURRMAX]={USD,DRACHMA,DMARK,POUND,GUILDER};
char currDesc[CURRMAX][MAX]={"US Dollars","Greek Drachmas","German Marks",
"English Pounds","Dutch Guilders"};

printf("\nCode Currencies");
printf("\n\n(U) US Dollar");
printf("\n(D) Greek Drachmas");
printf("\n(M) German Marks");
printf("\n(P) English Pounds");
printf("\n(G) Dutch Guilders");
//for(i=0;i<CURRMAX;i++)
//printf("\n%s",currDesc[i]);

printf("\n\n\nSelect the Code for the Currency you wish to Convert From > ");
scanf("%s",&fromCurr);
fflush(stdin);
printf("\n\n\nSelect the Code for the Currency you wish to Convert To > ");
scanf("%s",&toCurr);
fflush(stdin);
printf("\nEnter the amount of Monetary Units (i.e dollars) to be converted > ");
scanf("%.2f",&units);

printf("%c",fromCurr);
printf("%c",toCurr);
// Conversion work here.

return 0;
}