lclarius
asked on
Error Monster are Here " currency conversion meun "
I'm getting an error on Miracle C Compiler (r3.2), written by bts.
C:\Program Files\Miracle C\Currencyconvlisaclariusw eekfive.c: line 56: variable 'ch' not found
'ch=getch()'
aborting compile
#include <stdio.h> /*Currency Converison Menu */
void main(void)
{ /*beginning functionality*/ //Display five foreign currencies for one US Dollar //
float AUD,CAD,EUR,GBP,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
{char repeat = ('n');
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
}
convert();
printf("Select a currency type\n\n");
printf("1=Austrialia Dollar 2=United Kingdom Pound 3= Canadian Dollar 4=European Euro 5=Mexican Pesos\n");
printf("Select the 4=Canadian Dollars currency type\n\n");
{
int AUD,CAD,GBP,EUR,MXN,US;
AUD=1;
CAD=2;
GBP=3;
EUR=4;
MXN=5;
// Display and print //
printf("You selected something other than 1 to 5");
printf("Validate input for USdollar amount\n");
printf("Dollar amount must be between .01 to 1000.00. \n");
ch=getch();
switch(ch) //is the best thing to use for menu driven programs
{
case '1':
printf("You selected 1\n");
break;
case '2':
printf("You selected 2\n");
break;
case '3':
printf("You selected 3\n");
break;
case '4':
printf("You selected 4\n");
break;
case '5':
printf("You selected 5\n");
break;
default:
printf("You selected something other than 1 to 5");
}
}
}
C:\Program Files\Miracle C\Currencyconvlisaclariusw
'ch=getch()'
aborting compile
#include <stdio.h> /*Currency Converison Menu */
void main(void)
{ /*beginning functionality*/ //Display five foreign currencies for one US Dollar //
float AUD,CAD,EUR,GBP,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
{char repeat = ('n');
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
}
convert();
printf("Select a currency type\n\n");
printf("1=Austrialia Dollar 2=United Kingdom Pound 3= Canadian Dollar 4=European Euro 5=Mexican Pesos\n");
printf("Select the 4=Canadian Dollars currency type\n\n");
{
int AUD,CAD,GBP,EUR,MXN,US;
AUD=1;
CAD=2;
GBP=3;
EUR=4;
MXN=5;
// Display and print //
printf("You selected something other than 1 to 5");
printf("Validate input for USdollar amount\n");
printf("Dollar amount must be between .01 to 1000.00. \n");
ch=getch();
switch(ch) //is the best thing to use for menu driven programs
{
case '1':
printf("You selected 1\n");
break;
case '2':
printf("You selected 2\n");
break;
case '3':
printf("You selected 3\n");
break;
case '4':
printf("You selected 4\n");
break;
case '5':
printf("You selected 5\n");
break;
default:
printf("You selected something other than 1 to 5");
}
}
}
I sure don't see where it's defined.
ASKER
that could very well be the reason ..........
i'm assuming that your refering to declaring - I'm still getting error see below
Miracle C Compiler (r3.2), written by bts.
C:\Program Files\Miracle C\Currencyconvlisaclariusw eekfive.c: line 60: variable 'ch' not found
'ch=getch()'
aborting compile
#include <stdio.h> /*Currency Converison Menu */
int main(void)
{
//Declare main function variables and initalize as needed
/*beginning functionality*/ //Display five foreign currencies for one US Dollar //
float AUD,CAD,EUR,GBP,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
{char repeat = ('n');
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
}
convert();
printf("Select a currency type\n\n");
printf("1=Austrialia Dollar 2=United Kingdom Pound 3= Canadian Dollar 4=European Euro 5=Mexican Pesos\n");
printf("Select the 4=Canadian Dollars currency type\n\n");
{
int AUD,CAD,GBP,EUR,MXN,US;
AUD=1;
CAD=2;
GBP=3;
EUR=4;
MXN=5;
// Display and print //
printf("You selected something other than 1 to 5");
printf("Validate input for USdollar amount\n");
printf("Dollar amount must be between .01 to 1000.00. \n");
ch=getch();
switch(ch) //is the best thing to use for menu driven programs
{
case '1':
printf("You selected 1\n");
break;
case '2':
printf("You selected 2\n");
break;
case '3':
printf("You selected 3\n");
break;
case '4':
printf("You selected 4\n");
break;
case '5':
printf("You selected 5\n");
break;
default:
printf("You selected something other than 1 to 5");
}
}
}
AUS=(1);
if EUR==4);
{
else if (GBP==3);
else if (AUD==1);
else if (CAD==2);
else if (MXN==5);
}
printf("Number 1 Canadian Dollars has been selected\n\n");
float AUD,CAD,GBP,EUR,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n"CAD,US};
//Display title page and date of conversion //
printf("Currency Conversion\n"); /* Title of Currency Exchange Rates */
printf("October 13,2004\n"); /* Date of Currency Exchange Rates */
printf("\n"); /*Blank line */
getch();
return 0;
} /*THE END*/
i'm assuming that your refering to declaring - I'm still getting error see below
Miracle C Compiler (r3.2), written by bts.
C:\Program Files\Miracle C\Currencyconvlisaclariusw
'ch=getch()'
aborting compile
#include <stdio.h> /*Currency Converison Menu */
int main(void)
{
//Declare main function variables and initalize as needed
/*beginning functionality*/ //Display five foreign currencies for one US Dollar //
float AUD,CAD,EUR,GBP,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
{char repeat = ('n');
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
}
convert();
printf("Select a currency type\n\n");
printf("1=Austrialia Dollar 2=United Kingdom Pound 3= Canadian Dollar 4=European Euro 5=Mexican Pesos\n");
printf("Select the 4=Canadian Dollars currency type\n\n");
{
int AUD,CAD,GBP,EUR,MXN,US;
AUD=1;
CAD=2;
GBP=3;
EUR=4;
MXN=5;
// Display and print //
printf("You selected something other than 1 to 5");
printf("Validate input for USdollar amount\n");
printf("Dollar amount must be between .01 to 1000.00. \n");
ch=getch();
switch(ch) //is the best thing to use for menu driven programs
{
case '1':
printf("You selected 1\n");
break;
case '2':
printf("You selected 2\n");
break;
case '3':
printf("You selected 3\n");
break;
case '4':
printf("You selected 4\n");
break;
case '5':
printf("You selected 5\n");
break;
default:
printf("You selected something other than 1 to 5");
}
}
}
AUS=(1);
if EUR==4);
{
else if (GBP==3);
else if (AUD==1);
else if (CAD==2);
else if (MXN==5);
}
printf("Number 1 Canadian Dollars has been selected\n\n");
float AUD,CAD,GBP,EUR,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n"CAD,US};
//Display title page and date of conversion //
printf("Currency Conversion\n"); /* Title of Currency Exchange Rates */
printf("October 13,2004\n"); /* Date of Currency Exchange Rates */
printf("\n"); /*Blank line */
getch();
return 0;
} /*THE END*/
You still haven't defined ch anywhere. Add
int ch;
somewhere in scope before you use it (as the recipient to getch()).
int ch;
somewhere in scope before you use it (as the recipient to getch()).
Yup. Since getch() is typed as int, stick in a:
int ch;
and change you cases to ints, or convert ch to a char and use that new variable for the switch.
int ch;
and change you cases to ints, or convert ch to a char and use that new variable for the switch.
ASKER
ok , i have added int ch; before using getch (ch)
however i don't understand what your telling me to do in case
could you clarify for me please ---- i'm new at C and learning would like to understand please help lclarius
#include <stdio.h> /*Currency Converison Menu */
int main(void)
{
//Declare main function variables and initalize as needed
/*beginning functionality*/ //Display five foreign currencies //
float AUD,CAD,EUR,GBP,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
{char repeat = ('n');
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
}
convert();
printf("Select a currency type\n\n");
printf("1=Austrialia Dollar 2=United Kingdom Pound 3= Canadian Dollar 4=European Euro 5=Mexican Pesos\n");
printf("Select the 4=Canadian Dollars currency type\n\n");
{
int AUD,CAD,GBP,EUR,MXN,US;
AUD=1;
CAD=2;
GBP=3;
EUR=4;
MXN=5;
// Display and print //
printf("You selected something other than 1 to 5");
printf("Validate input for USdollar amount\n");
printf("Dollar amount must be between .01 to 1000.00. \n");
int ch;
ch=getch();
switch(ch) //is the best thing to use for menu driven programs
{
case '1':
printf("You selected 1\n");
break;
case '2':
printf("You selected 2\n");
break;
case '3':
printf("You selected 3\n");
break;
case '4':
printf("You selected 4\n");
break;
case '5':
printf("You selected 5\n");
break;
default:
printf("You selected something other than 1 to 5");
}
}
}
AUS=(1);
if EUR==4);
{
else if (GBP==3);
else if (AUD==1);
else if (CAD==2);
else if (MXN==5);
}
printf("Number 1 Canadian Dollars has been selected\n\n");
float AUD,CAD,GBP,EUR,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n"CAD,US};
//Display title page and date of conversion //
printf("Currency Conversion\n"); /* Title of Currency Exchange Rates */
printf("October 13,2004\n"); /* Date of Currency Exchange Rates */
printf("\n"); /*Blank line */
getch();
return 0;
} /*THE END*/
however i don't understand what your telling me to do in case
could you clarify for me please ---- i'm new at C and learning would like to understand please help lclarius
#include <stdio.h> /*Currency Converison Menu */
int main(void)
{
//Declare main function variables and initalize as needed
/*beginning functionality*/ //Display five foreign currencies //
float AUD,CAD,EUR,GBP,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
{char repeat = ('n');
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
}
convert();
printf("Select a currency type\n\n");
printf("1=Austrialia Dollar 2=United Kingdom Pound 3= Canadian Dollar 4=European Euro 5=Mexican Pesos\n");
printf("Select the 4=Canadian Dollars currency type\n\n");
{
int AUD,CAD,GBP,EUR,MXN,US;
AUD=1;
CAD=2;
GBP=3;
EUR=4;
MXN=5;
// Display and print //
printf("You selected something other than 1 to 5");
printf("Validate input for USdollar amount\n");
printf("Dollar amount must be between .01 to 1000.00. \n");
int ch;
ch=getch();
switch(ch) //is the best thing to use for menu driven programs
{
case '1':
printf("You selected 1\n");
break;
case '2':
printf("You selected 2\n");
break;
case '3':
printf("You selected 3\n");
break;
case '4':
printf("You selected 4\n");
break;
case '5':
printf("You selected 5\n");
break;
default:
printf("You selected something other than 1 to 5");
}
}
}
AUS=(1);
if EUR==4);
{
else if (GBP==3);
else if (AUD==1);
else if (CAD==2);
else if (MXN==5);
}
printf("Number 1 Canadian Dollars has been selected\n\n");
float AUD,CAD,GBP,EUR,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n"CAD,US};
//Display title page and date of conversion //
printf("Currency Conversion\n"); /* Title of Currency Exchange Rates */
printf("October 13,2004\n"); /* Date of Currency Exchange Rates */
printf("\n"); /*Blank line */
getch();
return 0;
} /*THE END*/
ASKER
how do I convert ch to a char and use new variable for the switch
ASKER
guys i'm in need of your help please
> how do I convert ch to a char and use new variable for the switch
switch() expects an int as an argument.
getch() and getchar() return an int.
chars, when assigned to an int, are automatically converted to int.
In other words, you don't have to do anything.
switch() expects an int as an argument.
getch() and getchar() return an int.
chars, when assigned to an int, are automatically converted to int.
In other words, you don't have to do anything.
ASKER
ok i get the jif of this but my code is throwing off this error.......
i'm confused very ........ please have patients with me ...... cause i want to pull my hair out :(
Miracle C Compiler (r3.2), written by bts.
C:\Program Files\Miracle C\Currencyconvlisaclariusw eekfive.c: line 61: Parse Error, expecting `'}''
'int ch'
aborting compilee jif of that - my code is throwing off this error
i'm confused very ........ please have patients with me ...... cause i want to pull my hair out :(
Miracle C Compiler (r3.2), written by bts.
C:\Program Files\Miracle C\Currencyconvlisaclariusw
'int ch'
aborting compilee jif of that - my code is throwing off this error
ASKER
i know its expecting an bracket that is what i'm getting out of the error .........
ASKER
i can't go to bed without working this out ........ i'm on cst here1:46 needing help with understanding ......how to correct this mess i'm in ............lclarius
ASKER
There was error parsing your query.
c is not valid field. The following are valid fields: title body content
c is not valid field. The following are valid fields: title body content
This is 'C', not C++ so you have to declare after a '{'.
use:
int AUD,CAD,GBP,EUR,MXN,US,ch;
I hope you got to bed. ;)
Next time, post 'C' questions in the 'C' area. You'll get a quicker response.
Paul
use:
int AUD,CAD,GBP,EUR,MXN,US,ch;
I hope you got to bed. ;)
Next time, post 'C' questions in the 'C' area. You'll get a quicker response.
Paul
Hello,
Post your source file here. I must compile it. I think that there are some mistakes in it.
in C you must declare variables at the start of function.
Thanks
-FA
Post your source file here. I must compile it. I think that there are some mistakes in it.
in C you must declare variables at the start of function.
Thanks
-FA
>>in C you must declare variables at the start of function.
Not quite!! Its actually at the start of a block.
E.G.. You CAN do:
...
for ( i = 0; i < 10; i++ )
{
int x = 128;
...
}
Paul
Not quite!! Its actually at the start of a block.
E.G.. You CAN do:
...
for ( i = 0; i < 10; i++ )
{
int x = 128;
...
}
Paul
hi lclarius,
the code you posted has has several bugs / problems.
actually, it is quite messed up. please write what kind of help do you want.
do you want just to get the code running or to understand what needs to be
corrected and how?
good luck,
georg
the code you posted has has several bugs / problems.
actually, it is quite messed up. please write what kind of help do you want.
do you want just to get the code running or to understand what needs to be
corrected and how?
good luck,
georg
ASKER
here is what the program should do
1. Present a menu of currencies with one choice to end the program.
2. On a currency choice ask $US you want to convert or 0 to return to the menu.
3. Here you might have a few choices
a. Loop around the $US choice, allowing a repeat of $US dollar amounts, invalid values with error messages and only exiting back to the menu on a 0 value.
b. One response only, display conversion if valid amount, display error message if not valid, return to menu on 0, but in all three choices return to menu as you are only allowing one currency conversion per menu choice.
4. Repeat 1
#include <stdio.h> /*Currency Converison Menu */
void main(void)
{
//Declare main function variables and initalize as needed
/*beginning functionality*/ //Display five foreign currencies //
char ch;
float AUD,CAD,EUR,GBP,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
convert(); /*
printf("Select a currency type\n\n");
printf("1=Austrialia Dollar 2=United Kingdom Pound 3= Canadian Dollar 4=European Euro 5=Mexican Pesos\n");
printf("Select the 4=Canadian Dollars currency type\n\n");
{
int AUD,CAD,GBP,EUR,MXN,US;
AUD=1;
CAD=2;
GBP=3;
EUR=4;
MXN=5;
// Display and print //
printf("You selected something other than 1 to 5");
printf("Validate input for USdollar amount\n");
printf("Dollar amount must be between .01 to 1000.00. \n");
char option /* using variable to obtain key pressed */
}
ch=getch();
switch(ch) //is the best thing to use for menu driven programs
{
case '1':
printf("You selected 1\n");
break;
case '2':
printf("You selected 2\n");
break;
case '3':
printf("You selected 3\n");
break;
case '4':
printf("You selected 4\n");
break;
case '5':
printf("You selected 5\n");
break;
default:
printf("You selected something other than 1 to 5");
}
}
}
AUS=(1);
if EUR==4);
{
else if (GBP==3);
else if (AUD==1);
else if (CAD==2);
else if (MXN==5);
}
printf("Number 1 Canadian Dollars has been selected\n\n");
float AUD,CAD,GBP,EUR,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n"CAD,US};
//Display title page and date of conversion //
printf("Currency Conversion\n"); /* Title of Currency Exchange Rates */
printf("October 28,2004\n"); /* Date of Currency Exchange Rates */
printf("\n"); /*Blank line */
getch();
return 0;
{ /*THE END*/
1. Present a menu of currencies with one choice to end the program.
2. On a currency choice ask $US you want to convert or 0 to return to the menu.
3. Here you might have a few choices
a. Loop around the $US choice, allowing a repeat of $US dollar amounts, invalid values with error messages and only exiting back to the menu on a 0 value.
b. One response only, display conversion if valid amount, display error message if not valid, return to menu on 0, but in all three choices return to menu as you are only allowing one currency conversion per menu choice.
4. Repeat 1
#include <stdio.h> /*Currency Converison Menu */
void main(void)
{
//Declare main function variables and initalize as needed
/*beginning functionality*/ //Display five foreign currencies //
char ch;
float AUD,CAD,EUR,GBP,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
convert(); /*
printf("Select a currency type\n\n");
printf("1=Austrialia Dollar 2=United Kingdom Pound 3= Canadian Dollar 4=European Euro 5=Mexican Pesos\n");
printf("Select the 4=Canadian Dollars currency type\n\n");
{
int AUD,CAD,GBP,EUR,MXN,US;
AUD=1;
CAD=2;
GBP=3;
EUR=4;
MXN=5;
// Display and print //
printf("You selected something other than 1 to 5");
printf("Validate input for USdollar amount\n");
printf("Dollar amount must be between .01 to 1000.00. \n");
char option /* using variable to obtain key pressed */
}
ch=getch();
switch(ch) //is the best thing to use for menu driven programs
{
case '1':
printf("You selected 1\n");
break;
case '2':
printf("You selected 2\n");
break;
case '3':
printf("You selected 3\n");
break;
case '4':
printf("You selected 4\n");
break;
case '5':
printf("You selected 5\n");
break;
default:
printf("You selected something other than 1 to 5");
}
}
}
AUS=(1);
if EUR==4);
{
else if (GBP==3);
else if (AUD==1);
else if (CAD==2);
else if (MXN==5);
}
printf("Number 1 Canadian Dollars has been selected\n\n");
float AUD,CAD,GBP,EUR,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n"CAD,US};
//Display title page and date of conversion //
printf("Currency Conversion\n"); /* Title of Currency Exchange Rates */
printf("October 28,2004\n"); /* Date of Currency Exchange Rates */
printf("\n"); /*Blank line */
getch();
return 0;
{ /*THE END*/
I'd suggest you re-read georg's comment.
We cannot fix your code as this is homework, we can only help you fix it.
Paul
We cannot fix your code as this is homework, we can only help you fix it.
Paul
I notice that you havent made the changes I suggested earlier. Didnt they work?
Paul
Paul
ASKER
Miracle C Compiler (r3.2), written by bts.
Compiling C:\Program Files\Miracle C\currencyconversionlisacl ariusweekf ive1.c
main
Compiler internal error
(cc.y, 2373) C:\Program Files\Miracle C\currencyconversionlisacl ariusweekf ive1 : 51: call outside proc
Please report the above message with your source code to the author
'ch=getch()'
i'm getting this errror - i really need to know how to correct code so it will compile, build and execute
thanks guys lclarius
Compiling C:\Program Files\Miracle C\currencyconversionlisacl
main
Compiler internal error
(cc.y, 2373) C:\Program Files\Miracle C\currencyconversionlisacl
Please report the above message with your source code to the author
'ch=getch()'
i'm getting this errror - i really need to know how to correct code so it will compile, build and execute
thanks guys lclarius
The trick to getting it all to compile is to remove most of the code and slowly insert it back until something goes wrong.
I'd suggest you start with:
#include <stdio.h> /*Currency Converison Menu */
void main(void)
{
//Declare main function variables and initalize as needed
/*beginning functionality*/ //Display five foreign currencies //
char ch;
float AUD,CAD,EUR,GBP,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
}
and slowly add the rest bit by bit.
Paul
I'd suggest you start with:
#include <stdio.h> /*Currency Converison Menu */
void main(void)
{
//Declare main function variables and initalize as needed
/*beginning functionality*/ //Display five foreign currencies //
char ch;
float AUD,CAD,EUR,GBP,MXN,US;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
}
and slowly add the rest bit by bit.
Paul
ASKER
ok will do - lclarius
1. if EUR==4); Change To ==> if (EUR==4)
2. Change
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n"CAD,US};
to
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n",CAD,US);
You used } instead of ) and forgot , character
3. You declared AUD, ... variables as float once and later declared them as int. You can't redefine variables in one scope.
Change the name of second group variables to start with i such as iAUD,....
-FA
2. Change
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n"CAD,US};
to
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n",CAD,US);
You used } instead of ) and forgot , character
3. You declared AUD, ... variables as float once and later declared them as int. You can't redefine variables in one scope.
Change the name of second group variables to start with i such as iAUD,....
-FA
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Guys YOU ARE THE BEST .....I surly didnot want to go global however it worked
Compiled
Built
and Executed - this is what code produce in DOS
Currency Conversion
1.401930 Austrialia Dollar is equivalent to 1.000000 US Dollar
1.275400 Canadian Dollars is equivalent to 1.000000 US Dollar
0.523340 United Kingdom Pound is equivalent to 1.000000 US Dollar
0.812612 European Euro is equivalent to 1.000000 US Dollar
11.405000 Mexican Pesos is equivalent to 1.000000 US Dollar
#include <stdio.h> /*Currency Converison Menu */
/* Declaring and intalizing Global variables*/
float AUD,CAD,EUR,GBP,MXN,US;
void main(void)
{
//Declare main function variables and initalize as needed
/*beginning functionality*/ //Display five foreign currencies //
char ch;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
}
Compiled
Built
and Executed - this is what code produce in DOS
Currency Conversion
1.401930 Austrialia Dollar is equivalent to 1.000000 US Dollar
1.275400 Canadian Dollars is equivalent to 1.000000 US Dollar
0.523340 United Kingdom Pound is equivalent to 1.000000 US Dollar
0.812612 European Euro is equivalent to 1.000000 US Dollar
11.405000 Mexican Pesos is equivalent to 1.000000 US Dollar
#include <stdio.h> /*Currency Converison Menu */
/* Declaring and intalizing Global variables*/
float AUD,CAD,EUR,GBP,MXN,US;
void main(void)
{
//Declare main function variables and initalize as needed
/*beginning functionality*/ //Display five foreign currencies //
char ch;
AUD=1.40193f;
GBP=0.52334f;
CAD=1.2754f;
EUR=0.812612f;
MXN=11.405f;
US=1.00f;
printf("Currency Conversion\n\n");
printf("%f Austrialia Dollar is equivalent to %f US Dollar\n",AUD,US);
printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
printf("%f Mexican Pesos is equivalent to %f US Dollar\n",MXN,US);
getch(); /* WAITS UNTIL A KEY IS PRESSED, getch() WAIT FOR A KEY AND TELLS YOU WHICH */
}
ASKER
many thanks to Paul , George & FA thanks for having all the patients in the world
lisa
lisa
Errm... I think you may have been a bit hasty.
Re-read my post and you will see:
>>... and slowly insert it back until something goes wrong.
What you have now does nothing. You meed to add more stuff to make it:
1. Ask for an amount.
2. Convert it.
3. Print the result.
Sadly, you've accepted an answer so I'd suggest you repost.
Paul
Re-read my post and you will see:
>>... and slowly insert it back until something goes wrong.
What you have now does nothing. You meed to add more stuff to make it:
1. Ask for an amount.
2. Convert it.
3. Print the result.
Sadly, you've accepted an answer so I'd suggest you repost.
Paul