Link to home
Start Free TrialLog in
Avatar of Rfusco
Rfusco

asked on

Problems

I am still very confused. I have worked on this for 2 full days and it still gives me errors. I am at a stand still.  /******************************************************************************************************/
 
/*Currency Conversion Program created by Rebecca Fusco 8/4/04*/
 
#include <stdio.h>              /*header*/
 
/*five selected world currency conversions to 1.00 US dollar,float datatype*/
int main(void)
 
{                        /*beginning function*/
/*world country selections for currency conversions:Canada,Europe,United Kingdom,Japan,Russia,United States*/                                      
float CAD,EUR,GBP,JPY,RUR,US;                                                
 
/*assign values to selected countries,reference retrieved from live market
  at http://www.xe.com/effective as of 8/4/04 18:44 GMT*/                                        
    CAD=1.31751f;
    EUR=0.829643f;              
    GBP=0.548242f;
    JPY=110.631f;
    RUR=29.1800f;                                                                                  
    US=1.00f;
                                 
    printf("Currency Conversion\n\n");          /*displays title and double space*/
/*declare variables for currency rate from European Euro converted to the United States Dollar*/                                                          
    printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
/*declare variables for currency rate from United Kingdom Pound to the United States Dollar*/                                                                          
    printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
/*declare variables for currency rate from Japanese Yens to the United States Dollar*/
    printf("%f Japanese Yens is equivalent to %f US Dollar\n",JPY,US);  
 /*declare variables for currency rate from Canadian Dollars to the United States Dollar*/
    printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
/*declare variables for currency rate from Russian Rubles converted to the United States Dollar*/                                                          
    printf("%f Russian Rubles is equivalant to %f US Dollar\n",RUR,US);
 
getch();
convert();
return 0;                          
}                                   /*ends*/    
 
/**************************************************************************************************/                              
  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
#select Canada "4"
int main(void)

{
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");
}
int EUR,GBP,JPY,CAD,RUR,US;  
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
char option;
option=getch();
CAD=(4);
if EUR==1);
{
else if(GBP==2);
else if (JPY==3);
else if (CAD==4);
else if (RUR==5);
}
printf("Number 4 Canadian Dollars has been selected\n\n");
 
float CAD,EUR,GBP,JPY,RUR,US;  
    CAD=1.31751f;
    EUR=0.829643f;              
    GBP=0.548242f;
    JPY=110.631f;
    RUR=29.1800f;                                                                                  
    US=1.00f;  
    printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n"CAD,US};
getch();
convert();
return 0;                          
}
                   
               
 
 
 
 
Avatar of jkr
jkr
Flag of Germany image

Sorry, but that code is a mess - cleaned out most of the errors, you will need to start over from there:

/**************************************************************************************************/                

             
  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
#define Canada "4"
int main(void)

{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;  
char option;

   EUR=1;
   GBP=2;
   JPY=3;
   CAD=4;
   RUR=5;

   fCAD=1.31751f;
   fEUR=0.829643f;              
   fGBP=0.548242f;
   fJPY=110.631f;
   fRUR=29.1800f;                                                                                  
   fUS=1.00f;  

   printf("Select a currency type\n\n");
   printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
   printf("Select the 4=Canadian Dollars currency type\n\n");


option=getch();

if (option=='4') printf("Number 4 Canadian Dollars has been selected\n\n");


   printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n", fCAD,fUS);
getch();
convert();
return (0);            
}
Avatar of Rfusco
Rfusco

ASKER

Sorry but I am new to programming. I am getting a parse errorC:\Program Files\Miracle C\CC.c: line 69: Parse Error, expecting `')'' or `',''
'printf("The selected currency type is the Canadian dollars of %f equivlwnt to %f US Dollar\n",fCAD,fUS}'
aborting compile which mean it is missing brackets or par..but I cannot find it? I am error checking the numbers to validate whether its correct. Do I have to add in the else if for each number to do that? Thanks   e /******************************************************************************************************/
 
/*Currency Conversion Program created by Rebecca Fusco 8/4/04*/
 
#include <stdio.h>              /*header*/
 
/*five selected world currency conversions to 1.00 US dollar,float datatype*/
int main(void)
 
{                        /*beginning function*/
/*world country selections for currency conversions:Canada,Europe,United Kingdom,Japan,Russia,United States*/                                      
float CAD,EUR,GBP,JPY,RUR,US;                                                
 
/*assign values to selected countries,reference retrieved from live market
  at http://www.xe.com/effective as of 8/4/04 18:44 GMT*/                                        
    CAD=1.31751f;
    EUR=0.829643f;              
    GBP=0.548242f;
    JPY=110.631f;
    RUR=29.1800f;                                                                                  
    US=1.00f;
                                 
    printf("Currency Conversion\n\n");          /*displays title and double space*/
/*declare variables for currency rate from European Euro converted to the United States Dollar*/                                                          
    printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
/*declare variables for currency rate from United Kingdom Pound to the United States Dollar*/                                                                          
    printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
/*declare variables for currency rate from Japanese Yens to the United States Dollar*/
    printf("%f Japanese Yens is equivalent to %f US Dollar\n",JPY,US);  
 /*declare variables for currency rate from Canadian Dollars to the United States Dollar*/
    printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
/*declare variables for currency rate from Russian Rubles converted to the United States Dollar*/                                                          
    printf("%f Russian Rubles is equivalant to %f US Dollar\n",RUR,US);
 
getch();
convert();
return 0;                          
}                                   /*ends*/    
 
/**************************************************************************************************/                              
  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
#select Canada "4"
int main(void)

{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
    fCAD=1.31751f;
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");
option=getch();
if(option=='4') printf("Number 4 Canadian Dollars has been selected\n\n");
printf("Number 4 Canadian Dollars has been selected\n\n");
printf("The selected currency type is the Canadian dollars of %f equivlwnt to %f US Dollar\n",fCAD,fUS};
getch();
convert();
return 0;                          
}
                   
               
 
 
 
 
>>'printf("The selected currency type is the Canadian dollars of %f equivlwnt to %f US Dollar\n",fCAD,fUS}

That's one of the errors I corrected above (why did you use that line again? :o) - it has to end with a ');', e.g.

printf("The selected currency type is the Canadian dollars of %f equivlwnt to %f US Dollar\n",fCAD,fUS);

Avatar of Rfusco

ASKER

Dah!  I totally missed that. It is always something small and silly that you should catch. You are the best ever :-) So this error checks my program also? Or do I need to work on it more? Thanks Rebecca
You still need to define your 'convert()' function (if you still need it), apart from that, it *compiles* (which does nto mean that it will work). Since this seems to be an assignment, I won't give you the full code, but to outline what you should do:

Remove the

if (option=='4') printf("Number 4 Canadian Dollars has been selected\n\n");
printf("The selected currency type is the Canadian dollar of %f equivlwnt to %f US Dollar\n", fCAD,fUS);

part and make that read

switch(option) {

case '1':

printf("The selected currency type is the Euro of %f equivlwnt to %f US Dollar\n", fEUR,fUS);
break;

case '2':

printf("The selected currency type is the United Kingdom Pound of %f equivlwnt to %f US Dollar\n", fGBP,fUS);
break;

default:
printf("The selected currency type is invalid.\n");
}
Avatar of Rfusco

ASKER

/******************************************************************************************************/
 
I took out the'convert()' function as I do not think that I need it. Now I am getting a 2 default error message? I am lost on that one. C:\Program Files\Miracle C\CC.c: line 84: two defaults
'default: printf("The selected currency types 1,2,3,5 are invalid\n")'
aborting compile

 /*Currency Conversion Program created by Rebecca Fusco 8/4/04*/
 
#include <stdio.h>              /*header*/
 
/*five selected world currency conversions to 1.00 US dollar,float datatype*/
int main(void)
 
{                        /*beginning function*/
/*world country selections for currency conversions:Canada,Europe,United Kingdom,Japan,Russia,United States*/                                      
float CAD,EUR,GBP,JPY,RUR,US;                                                
 
/*assign values to selected countries,reference retrieved from live market
  at http://www.xe.com/effective as of 8/4/04 18:44 GMT*/                                        
    CAD=1.31751f;
    EUR=0.829643f;              
    GBP=0.548242f;
    JPY=110.631f;
    RUR=29.1800f;                                                                                  
    US=1.00f;
                                 
    printf("Currency Conversion\n\n");          /*displays title and double space*/
/*declare variables for currency rate from European Euro converted to the United States Dollar*/                                                          
    printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
/*declare variables for currency rate from United Kingdom Pound to the United States Dollar*/                                                                          
    printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
/*declare variables for currency rate from Japanese Yens to the United States Dollar*/
    printf("%f Japanese Yens is equivalent to %f US Dollar\n",JPY,US);  
 /*declare variables for currency rate from Canadian Dollars to the United States Dollar*/
    printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
/*declare variables for currency rate from Russian Rubles converted to the United States Dollar*/                                                          
    printf("%f Russian Rubles is equivalant to %f US Dollar\n",RUR,US);
 
getch();
return 0;                          
}                                   /*ends*/    
 
/**************************************************************************************************/                              
  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
   
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fCAD=1.31751f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");

option=getch();
switch(CAD==4)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalant to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalant to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalant to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian DOllars of %f equivalant to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalant to %f US  Dollar\n",fRUR,fUS);
break;
default:
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
}
printf("Number 4 Canadian Dollars has been selected\n\n");
getch();
return 0;                          
}
                   
               
 
 
 
 
It should be

  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
   EUR=1;
   GBP=2;
   JPY=3;
   CAD=4;
   RUR=5;
 
   
   fEUR=0.829643f;              
   fGBP=0.548242f;
   fJPY=110.631f;
   fCAD=1.31751f;
   fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 
   printf("Select a currency type\n\n");
   printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
   printf("Select the 4=Canadian Dollars currency type\n\n");

option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalant to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalant to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalant to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian DOllars of %f equivalant to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalant to %f US  Dollar\n",fRUR,fUS);
break;
default:
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
}
printf("Number 4 Canadian Dollars has been selected\n\n");
getch();
return 0;                          
}

since 'switch(CAD==4)' does not make any sense...
I suspect the assignment is to input an amount in US $, a currrency to convert it to, and then print out the $ in terms of that currency (
(or the reverse).  To do that,  you'll have to add another prompt "Please enter the amount", another input, and then do a very little bit of math.

Avatar of Rfusco

ASKER

Hi again :-) How come it only prints out up to the  the  printf("Select the 4=Canadian Dollars currency type\n\n");

and not after? Only prints up to when the switch starts? Thanks /******************************************************************************************************/
 
/*Currency Conversion Program created by Rebecca Fusco 8/4/04*/
 
#include <stdio.h>              /*header*/
 
/*five selected world currency conversions to 1.00 US dollar,float datatype*/
int main(void)
 
{                        /*beginning function*/
/*world country selections for currency conversions:Canada,Europe,United Kingdom,Japan,Russia,United States*/                                      
float CAD,EUR,GBP,JPY,RUR,US;                                                
 
/*assign values to selected countries,reference retrieved from live market
  at http://www.xe.com/effective as of 8/4/04 18:44 GMT*/                                        
    CAD=1.31751f;
    EUR=0.829643f;              
    GBP=0.548242f;
    JPY=110.631f;
    RUR=29.1800f;                                                                                  
    US=1.00f;
                                 
    printf("Currency Conversion\n\n");          /*displays title and double space*/
/*declare variables for currency rate from European Euro converted to the United States Dollar*/                                                          
    printf("%f European Euro is equivalent to %f US Dollar\n",EUR,US);
/*declare variables for currency rate from United Kingdom Pound to the United States Dollar*/                                                                          
    printf("%f United Kingdom Pound is equivalent to %f US Dollar\n",GBP,US);
/*declare variables for currency rate from Japanese Yens to the United States Dollar*/
    printf("%f Japanese Yens is equivalent to %f US Dollar\n",JPY,US);  
 /*declare variables for currency rate from Canadian Dollars to the United States Dollar*/
    printf("%f Canadian Dollars is equivalent to %f US Dollar\n",CAD,US);
/*declare variables for currency rate from Russian Rubles converted to the United States Dollar*/                                                          
    printf("%f Russian Rubles is equivalant to %f US Dollar\n",RUR,US);
 
getch();
return 0;                          
}                                   /*ends*/    
 
/**************************************************************************************************/                              
  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
   
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fCAD=1.31751f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");

option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalant to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalant to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalant to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian DOllars of %f equivalant to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalant to %f US  Dollar\n",fRUR,fUS);
break;
default:
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
}
printf("Number 4 Canadian Dollars has been selected\n\n");
getch();
return 0;                          
}
                   
               
 
 
 
 
You need to remove

printf("Number 4 Canadian Dollars has been selected\n\n");

That should be

  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
   EUR=1;
   GBP=2;
   JPY=3;
   CAD=4;
   RUR=5;
 
   
   fEUR=0.829643f;              
   fGBP=0.548242f;
   fJPY=110.631f;
   fCAD=1.31751f;
   fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 
   printf("Select a currency type\n\n");
   printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
   printf("Select the 4=Canadian Dollars currency type\n\n");

option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalant to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalant to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalant to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian DOllars of %f equivalant to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalant to %f US  Dollar\n",fRUR,fUS);
break;
default:
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
}
getch();
return 0;                          
}

BTW, why are you always posting both variants?

Avatar of Rfusco

ASKER

Still is not working? Should I not be able to print out something after the switch? I am still learning. How would I know if the switch is actually working? Thanks

#include <stdio.h>                            
int main(void)
{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
   
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fCAD=1.31751f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");

option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalant to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalant to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalant to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian DOllars of %f equivalant to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalant to %f US  Dollar\n",fRUR,fUS);
break;
default:
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
}
getch();
return 0;                          
}
                   
               
>> Still is not working?

Hmm, it works fine here. Or do you want that the user is *only* able to input '4'?

Avatar of Rfusco

ASKER

I want to get a currency code or selection number from the menu and validate whether its correct and print the equivalent in US dollars. For example the program may accept the input like

 Select the currency
 
1. Indian  Rupees
2.  Euro
3. Pound
0  Exit

If you want to add the exit option, just add

case '0':
printf("exiting...\n");
return (0);
break;

if you want it to run in a loop, that should be


  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
   EUR=1;
   GBP=2;
   JPY=3;
   CAD=4;
   RUR=5;
 
   
   fEUR=0.829643f;              
   fGBP=0.548242f;
   fJPY=110.631f;
   fCAD=1.31751f;
   fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
while(1) {
   printf("Select a currency type\n\n");
   printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles 0=exit\n");
   printf("Select the 4=Canadian Dollars currency type\n\n");

option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalant to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalant to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalant to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian DOllars of %f equivalant to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalant to %f US  Dollar\n",fRUR,fUS);
break;
case '0':
printf("exiting...\n");
return (0);
break;
default:
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
}

}
return 0;                          
}

Avatar of Rfusco

ASKER

I give up :-( No matter what I do the printout only says: Select a currency type
    1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles
   Select the 4=Canadian Dollars currency type it never does show that it has picked number 4. Thanks

/*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
   
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fCAD=1.31751f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 while(4){
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");

option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalant to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalant to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalant to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian DOllars of %f equivalant to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalant to %f US  Dollar\n",fRUR,fUS);
break;
case '0':
printf("exiting...\n");
return (0);
break;
default:
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
printf("Number 4 Canadian Dollars has been selected\n\n");
}
}
getch();
return 0;                          
}
                   
               
 
 
 
 
Well, I get the following output:

Select a currency type

1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russ
ian Rubles
Select the 4=Canadian Dollars currency type

The selected currency type is the Canadian DOllars of 1.317510 equivalant to 1.0
00000 US  Dollar

and that's what you wanted...
Or, do you want to see what the user entered also? Then, add

option=getch();
printf("You entered %c\n", option);
Avatar of Rfusco

ASKER

Yes that is what I want :-) but I do not get that printout"The selected currency type is the Canadian DOllars of 1.317510 equivalant to 1.0
00000 US  Dollar"
/*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
   
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fCAD=1.31751f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 while(4){
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");

option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalant to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalant to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalant to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian Dollars of %f equivalant to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalant to %f US  Dollar\n",fRUR,fUS);
break;
case '0':
printf("exiting...\n");
return (0);
break;
default:
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
printf("Number 4 Canadian Dollars has been selected\n\n");
}
}
getch();
return 0;                          
}
                   
               
 
 
 
 
You are not using the code I posted above, that's why.

BTW, why are you using

 while(4){

?
Avatar of Rfusco

ASKER

I thought that I had to use the 4 as the selected number. I changed it to 1 and it still will not print out that line. All of the code is the same as yours?
  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{
 
int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
   
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fCAD=1.31751f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 while(1){
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");
 
option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalant to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalant to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalant to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian DOllars of %f equivalant to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalant to %f US  Dollar\n",fRUR,fUS);
break;
case '0':
printf("exiting...\n");
return (0);
break;
default:
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
printf("Number 4 Canadian Dollars has been selected\n\n");
}
}
getch();
return 0;                          
}
                   
               
 
 
 
Hm, I just compiled your very code and it prints:

C:\tmp\cc>cconv
Select a currency type

1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russ
ian Rubles
Select the 4=Canadian Dollars currency type

The selected currency type is the Canadian DOllars of 1.317510 equivalant to 1.0
00000 US  Dollar
Select a currency type

1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russ
ian Rubles
Select the 4=Canadian Dollars currency type
Avatar of Rfusco

ASKER

For some reason it is only printing those same first three lines on my Miracle C complier. Tried to use scanf but am unsure as to where to put it. Thanks

 /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{
 
int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
   
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fCAD=1.31751f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 while(1){
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");

 option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalent to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalent to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalent to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian Dollars of %f equivalent to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalent to %f US  Dollar\n",fRUR,fUS);
break;
case '0':
printf("exiting...\n");
return (0);
break;
default:
scanf("%c", &option);
option=getch();
printf("You entered %c\n", option);
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
printf("Number 4 Canadian Dollars has been selected\n\n");
}
}
getch();
return 0;                          
}
                   
               

 
 
 
Err, a stupid remark - have you tried to press the "4" on your keyboard? This is somehow a requirement... *duck*
Avatar of Rfusco

ASKER

What do you mean? If I press the four it just adds in fours in the program where the curser is. Sorry for my ignorance but I know nothing :-(
Well, pressing the "4" when running your application is supposed to do the "menu selection" and display the above text (sorry if that sounds stupid)
Avatar of Rfusco

ASKER

Your a geninus :-) and the best of the best. Is there a way to assign triple extra extra points? You do work hard for them.  :-) The wierd thing though is now it prints out Select a currency type and 1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles twice Oh my!  
>>The wierd thing though is now it prints out Select a currency type and 1=European Euro 2=United Kingdom Pound
>>3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles twice Oh my!  

That's the loop - if you don't want that, make it read

 /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
   EUR=1;
   GBP=2;
   JPY=3;
   CAD=4;
   RUR=5;
 
   
   fEUR=0.829643f;              
   fGBP=0.548242f;
   fJPY=110.631f;
   fCAD=1.31751f;
   fRUR=29.1800f;                                                                                  
    fUS=1.00f;
   printf("Select a currency type\n\n");
   printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
   printf("Select the 4=Canadian Dollars currency type\n\n");

while(1){

printf("Enter your choice:");

option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalent to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalent to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalent to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian Dollars of %f equivalent to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalent to %f US  Dollar\n",fRUR,fUS);
break;
case '0':
printf("exiting...\n");
return (0);
break;
default:
scanf("%c", &option);
option=getch();
printf("You entered %c\n", option);
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
printf("Number 4 Canadian Dollars has been selected\n\n");
}
}
getch();
return 0;                          
}
Avatar of Rfusco

ASKER

Thank you so much. I have learned so much from you today that I well carry it all with me for a life time. Your talents are amazing. Sincerest thanks Rebecca
You're most welcome, but don't exaggerate :o)
Avatar of Rfusco

ASKER

Hi again :-) Sorry to bother you but I was wondering if I only wanted to print out the 4 option as suggested in the program what are some ways to try and do that without selecting the other invalid options of 1,2,3,5? Thanks in advance
/**************************************************************************************************/                              
  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{
 
int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
   
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fCAD=1.31751f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");
 while(1) {
 printf("enter your choice:");
 option=getch();
switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalent to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalent to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalent to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian Dollars of %f equivalent to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalent to %f US  Dollar\n",fRUR,fUS);
break;
case '0':
printf("exiting...\n");
return (0);
break;
default:
scanf("%c", & option);
option=getch();
printf("You entered %c\n", option);
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
printf("Number 4 Canadian Dollars has been selected\n\n");
}
}
getch();
return 0;                          
}
                   
 
               
 

 
 
Well, you could just use

 option=255;
 while ( ! (option == '4' || option == '0')) {
 printf("enter your choice (must be '4'):");
 option=getch();
 }
Avatar of Rfusco

ASKER

Like this? I get a parse error? I thought that it meant my brackets are placed wrong but I do not see how? I think that I still need the switch statement so I left it in for the switch? Thanks
  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{
 
int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
    EUR=1;
    GBP=2;
    JPY=3;
    CAD=4;
    RUR=5;
   
   
    fEUR=0.829643f;              
    fGBP=0.548242f;
    fJPY=110.631f;
    fCAD=1.31751f;
    fRUR=29.1800f;                                                                                  
    fUS=1.00f;  
 
    printf("Select a currency type\n\n");
    printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
    printf("Select the 4=Canadian Dollars currency type\n\n");
 option=255;
 while ( ! (option == '4' || option == '0')) {
  printf("enter your choice (must be '4'):");
 option=getch();
switch(option)
         
}
case '1':
printf("The selected currency type is the European Euro of %f equivalent to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalent to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalent to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian Dollars of %f equivalent to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalent to %f US  Dollar\n",fRUR,fUS);
break;
case '0':
printf("exiting...\n");
return (0);
break;
default:
scanf("%c", & option);
option=getch();
printf("You entered %c\n", option);
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
printf("Number 4 Canadian Dollars has been selected\n\n");
}
}
getch();
return 0;                          
}
                   

 

 
 
Not quite, more like

/**************************************************************************************************/                              
  /*Select a currency conversion type by code number 8/11/04*/
#include <stdio.h>                            
int main(void)
{

int EUR,GBP,JPY,CAD,RUR,US;  
float fCAD,fEUR,fGBP,fJPY,fRUR,fUS;
char option;
   EUR=1;
   GBP=2;
   JPY=3;
   CAD=4;
   RUR=5;
 
   
   fEUR=0.829643f;              
   fGBP=0.548242f;
   fJPY=110.631f;
   fCAD=1.31751f;
   fRUR=29.1800f;                                                                                  
    fUS=1.00f;  

    printf("Select a currency type\n\n");
   printf("1=European Euro 2=United Kingdom Pound 3=Japanese Yens 4=Canadian Dollars 5=Russian Rubles\n");
   printf("Select the 4=Canadian Dollars currency type\n\n");

while(1) {

 option=255;
while ( ! (option == '4' || option == '0')) {
printf("enter your choice (must be '4'):\n");
option=getch();
}

switch(option)
{
case '1':
printf("The selected currency type is the European Euro of %f equivalent to %f US  Dollar\n",fEUR,fUS);
break;
case '2':
printf("The selected currency type is the United Kingdom Pound of %f equivalent to %f US  Dollar\n",fGBP,fUS);
break;
case'3':
printf("The selected currency type is the Japanese Yens of %f equivalent to %f US  Dollar\n",fJPY,fUS);
break;
case'4':
printf("The selected currency type is the Canadian Dollars of %f equivalent to %f US  Dollar\n",fCAD,fUS);
break;
case '5':
printf("The selected currency type is the Russian Rubles of %f equivalent to %f US  Dollar\n",fRUR,fUS);
break;
case '0':
printf("exiting...\n");
return (0);
break;
default:
scanf("%c", & option);
option=getch();
printf("You entered %c\n", option);
printf("The selected currency types 1,2,3,5 are invalid\n");
break;
printf("Number 4 Canadian Dollars has been selected\n\n");
}
}
getch();
return 0;                          
}
Avatar of Rfusco

ASKER

Oh I left out the while (1) as I thought that it would not be necessary. I was wondering why does the first while choice have to be 1? Is there a specific purpose for the 1? I understand now that the option is what ever you assign it so the 255 is just a randomly picked number. If I am right here than I can say see I am learning :-) I am going to have to sign up for life :-) Thanks
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Rfusco

ASKER

Thannks and have a great day.