Solved

Problems

Posted on 2004-08-09
36
227 Views
Last Modified: 2010-04-15
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;                          
}
                   
               
 
 
 
 
0
Comment
Question by:Rfusco
  • 18
  • 17
36 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 11754027
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);            
}
0
 

Author Comment

by:Rfusco
ID: 11754340
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;                          
}
                   
               
 
 
 
 
0
 
LVL 86

Expert Comment

by:jkr
ID: 11754363
>>'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);

0
 

Author Comment

by:Rfusco
ID: 11754503
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
0
 
LVL 86

Expert Comment

by:jkr
ID: 11754605
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");
}
0
 

Author Comment

by:Rfusco
ID: 11755087
/******************************************************************************************************/
 
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;                          
}
                   
               
 
 
 
 
0
 
LVL 86

Expert Comment

by:jkr
ID: 11755298
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...
0
 
LVL 22

Expert Comment

by:grg99
ID: 11755317
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.

0
 

Author Comment

by:Rfusco
ID: 11755816
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;                          
}
                   
               
 
 
 
 
0
 
LVL 86

Expert Comment

by:jkr
ID: 11755934
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?

0
 

Author Comment

by:Rfusco
ID: 11756183
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;                          
}
                   
               
0
 
LVL 86

Expert Comment

by:jkr
ID: 11756452
>> Still is not working?

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

0
 

Author Comment

by:Rfusco
ID: 11756518
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

0
 
LVL 86

Expert Comment

by:jkr
ID: 11756653
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;                          
}

0
 

Author Comment

by:Rfusco
ID: 11756908
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;                          
}
                   
               
 
 
 
 
0
 
LVL 86

Expert Comment

by:jkr
ID: 11756934
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...
0
 
LVL 86

Expert Comment

by:jkr
ID: 11756949
Or, do you want to see what the user entered also? Then, add

option=getch();
printf("You entered %c\n", option);
0
 

Author Comment

by:Rfusco
ID: 11756983
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;                          
}
                   
               
 
 
 
 
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 86

Expert Comment

by:jkr
ID: 11757119
You are not using the code I posted above, that's why.

BTW, why are you using

 while(4){

?
0
 

Author Comment

by:Rfusco
ID: 11757368
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;                          
}
                   
               
 
 
 
0
 
LVL 86

Expert Comment

by:jkr
ID: 11758713
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
0
 

Author Comment

by:Rfusco
ID: 11758843
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;                          
}
                   
               

 
 
 
0
 
LVL 86

Expert Comment

by:jkr
ID: 11758864
Err, a stupid remark - have you tried to press the "4" on your keyboard? This is somehow a requirement... *duck*
0
 

Author Comment

by:Rfusco
ID: 11758903
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 :-(
0
 
LVL 86

Expert Comment

by:jkr
ID: 11758947
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)
0
 

Author Comment

by:Rfusco
ID: 11758969
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!  
0
 
LVL 86

Expert Comment

by:jkr
ID: 11758995
>>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;                          
}
0
 

Author Comment

by:Rfusco
ID: 11759085
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
0
 
LVL 86

Expert Comment

by:jkr
ID: 11759096
You're most welcome, but don't exaggerate :o)
0
 

Author Comment

by:Rfusco
ID: 11766132
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;                          
}
                   
 
               
 

 
 
0
 
LVL 86

Expert Comment

by:jkr
ID: 11766433
Well, you could just use

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

Author Comment

by:Rfusco
ID: 11766686
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;                          
}
                   

 

 
 
0
 
LVL 86

Expert Comment

by:jkr
ID: 11766835
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;                          
}
0
 

Author Comment

by:Rfusco
ID: 11766900
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
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 11767077
>> I understand now that the option is what ever you assign it so the 255 is just a randomly picked number.

Random as in terms of out of the range of values you want to test. Initially, I wrote "0" until realizing that this is our exit condition.
0
 

Author Comment

by:Rfusco
ID: 11767315
Thannks and have a great day.
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now