Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <iostream>
#include <string>
char Menu_Opt[4]; /* Menu Option */
char *ctime( const time_t *time );
float Org_Curr_Amt = 0.00; /* Original Currency Amount */
float New_Curr_Amt = 0.00; /* New Currency Amount */
char Currency_Desc[24][100] = {"American Dollar (USD)", "Australian Dollar (AUD)",
"Brazilian Real (BRL)", "British Pound (GBP)", "Canadian Dollar (CAD)",
"Chinese Yuan (CNY)", "Danish Krone (DKK)", "Euro (EUR)", "Hong Kong Dollar (HKD)",
"Indian Rupee (INR)", "Japanese Yen (JPY)", "Malaysian Ringgit (MYR)", "Mexican Peso (MXN)",
"New Zealand Dollar (NZD)", "Norwegian Kroner (NOK)", "Singapore Dollar (SGD)",
"South African Rand (ZAR)", "South Korean Won (KRW)", "Sri Lanka Rupee (LKR)",
"Swedish Krona (SEK)", "Swiss Franc (CHF)", "Taiwan Dollar (TVD)", "Thai Baht (THB)",
"Venezuelan Bolivar (YEB)"};
/* Descriptions of each of the currency types that can be converted */
float Curr_Conv_Factor; /* Individual currency conversion factor read from
file to be used to fill the array */
float Currency_Conv[24][24]; /* Array containing currency conversion factors */
int Row; /* Row position in currency conversion array */
int Column; /* Column position in currency conversion array */
struct tm *newtime
time_t aclock; /* Line 32 */
/* Definitions of each of the additional subroutines, (functions as they're called
in C, C++, and C#) for showing each of the currency conversion menu options, do
any selected conversion, or transfer to a different function. */
void USD_Menu();
int CLR_Screen(); /* Function to clear the screen and reposition the cursor
so that the menus do not scroll off the screen. */
std::fstream infile; /* Define/create object type to be used for accessing
the contents of the file. */
main()
{
std::fstream infile; /* Define/create object type to be used for accessing
the contents of the file. */
infile.open( "currency exchange rates.csv", std::ios::in );
std::string field;
while( infile.good() )
{
/* Check if the file is still good in your inner loops too */
for (Row = 0; Row < 24 && infile.good(); Row++)
{
for (Column = 0; Column < 24 && infile.good(); Column++)
{
if (Column == (24 - 1))
std::getline(infile, field);/* Last field on a line isn't comma-delimited */
else
std::getline(infile, field, ','); /* But the rest are */
Curr_Conv_Factor = std::atof(field.c_str()); /* Convert string to floating point numeric */
Currency_Conv[Row][Column] = Curr_Conv_Factor; /* Load each record read into the
appropriate array element */
}
}
}
system("mode con:lines=40");
system("mode con:cols=100");
time( &aclock ); // Get time in seconds /* Line 76 */
newtime = localtime( &aclock ); // Convert time to struct tm form
/* Print local time as a string */
printf( "Current date and time: %s", asctime( newtime ) );
/* Print Individual elements of time as a decimal */
/* Print Month as a decimal */
printf( "Month : %d \n", (1+(*newtime).tm_mon));
/* Print Day as a decimal */
printf( "Day : %d \n", (*newtime).tm_mday);
/* Print Year as a decimal */
printf( "Year : %d \n", (1900+(*newtime).tm_year));
USD_Menu();
return 0;
}
int CLR_Screen()
{
system ("cls");
return(0);
}
void USD_Menu()
{
CLR_Screen();
/* printf("Currency Conversion\n", month date year); */
printf("%sConversion Menu\n\n", Currency_Desc[0]);
printf("\nMenu1");
printf("\n");
printf("A02. USD to AUD Y02. Transfer to AUD Conversion Menu\n");
printf("A03. USD to BRL Y03. Transfer to BRL Conversion Menu\n");
printf("A04. USD to GBP Y04. Transfer to GBP Conversion Menu\n");
printf("A05. USD to CAD Y05. Transfer to CAD Conversion Menu\n");
printf("A06. USD to CNY Y06. Transfer to CNY Conversion Menu\n");
printf("A07. USD to DKK Y07. Transfer to DKK Conversion Menu\n");
printf("A08. USD to EUR Y08. Transfer to EUR Conversion Menu\n");
printf("A09. USD to HKD Y09. Transfer to HKD Conversion Menu\n");
printf("A10. USD to INR Y10. Transfer to INR Conversion Menu\n");
printf("A11. USD to JPY Y11. Transfer to JPY Conversion Menu\n");
printf("A12. USD to MYR Y12. Transfer to MYR Conversion Menu\n");
printf("A13. USD to MXN Y13. Transfer to MXN Conversion Menu\n");
printf("A14. USD to NZD Y14. Transfer to NZD Conversion Menu\n");
printf("A15. USD to NOK Y15. Transfer to NOK Conversion Menu\n");
printf("A16. USD to SGD Y16. Transfer to SGD Conversion Menu\n");
printf("A17. USD to ZAR Y17. Transfer to ZAR Conversion Menu\n");
printf("A18. USD to KRW Y18. Transfer to KRW Conversion Menu\n");
printf("A19. USD to LKR Y19. Transfer to LKR Conversion Menu\n");
printf("A20. USD to SEK Y20. Transfer to SEK Conversion Menu\n");
printf("A21. USD to CHF Y21. Transfer to CHF Conversion Menu\n");
printf("A22. USD to TVD Y22. Transfer to TVD Conversion Menu\n");
printf("A23. USD to THB Y23. Transfer to THB Conversion Menu\n");
printf("A24. USD to YEB Y24. Transfer to YEB Conversion Menu\n\n");
printf("Q. Exit Program\n");
printf("Option: ");
scanf("%s", Menu_Opt);
int Opt_Num;
Menu_Opt[0] = toupper(Menu_Opt[0]);
Opt_Num = atoi(Menu_Opt + 1);
if( Menu_Opt[0] == 'Q')
{
return;
}
if( Menu_Opt[0] != 'A' && Menu_Opt[0] != 'Y')
{
printf("\nInvalid menu option, program is now exiting");
return;
}
if( Opt_Num <= 1 || Opt_Num > 24)
{
printf("\nInvalid menu option, program is now exiting");
return;
}
if( strcmp(Menu_Opt,"A02") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[0][1];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[1], New_Curr_Amt);
}
if( strcmp(Menu_Opt,"A03") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[2][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[2], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A04") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[3][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[3], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A05") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[4][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[4], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A06") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[5][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[5], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A07") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[6][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[6], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A08") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[7][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[7], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A09") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[8][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[8], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A10") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[9][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[9], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A11") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[10][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[10], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A12") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[11][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[11], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A13") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[12][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[12], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A14") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[13][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[13], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A15") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[14][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[14], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A16") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[15][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[15], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A17") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[16][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[16], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A18") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[17][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[17], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A19") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[18][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[18], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A20") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[19][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[19], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A21") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[20][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[20], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A22") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[21][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[21], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A23") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[22][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[22], New_Curr_Amt);
}
if( strcmp(Menu_Opt, "A24") == 0)
{
printf("\nPlease enter your value of %s ", Currency_Desc[0]);
scanf("%g", &Org_Curr_Amt);
New_Curr_Amt = Org_Curr_Amt * Currency_Conv[23][0];
printf("\nYour Equivalent %s is %f\n", Currency_Desc[23], New_Curr_Amt);
}
}
I am now getting the following errors: