Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

currency conversion

Posted on 2004-10-27
12
Medium Priority
?
364 Views
Last Modified: 2010-04-17
Compiles ok, Builds ok but doesn't produce anything when I execute
Please help
        
#include <stdio.h>    
int main ()
{

         /*Declaring variables for five foreign nations, and there currencies
         for one USdollar and there NASD symbols, which are: */
         /* aud            Austrialia            1.40196  */
         /* cad            Canada             1.2754   */
         /* gpd            Great Britain         0.52434  */
         /* eur             Europe             0.812612 */
         /* mxn            Mexico             11.0425  */
                

// -----------------------------------------------------------------------------------------------------//

          float value, audcur, cadcur, gpdcur, eurcur, mxncur;
         
//------------------------------------------------------------------------------------------------------//

/* Variables for the denominations rate of the foreign currencies */
/* The variable names are representatives of foreign nations*/
     
          char British_unit[]="pounds";
          char Canadian_unit[]= "dollars";
          char European_unit[]= "euros";
          char Australian_unit[]="dollars";
          char Mexican_unit[]="pesos";
         
         
//-----------------------------------------------------------------------------------------------------//
           /*Display the value of the foreign exchange currency to one USdollar*/    
/*----------------------------------------------------------------------------------------------------- */
          scanf("%f ,&value"); /* for one USdollar */
          while (value !=  0.0)
          if(value<0.01&& value>1000.00)
{
      printf("Enter a dollar amount 0.01 to 1000.00 for all listed currencies to one USdollar");  

}else
{  
 
      /*Display report title and date of conversion */

      printf("***********************************************************************\n");
      printf("  Currency Conversion Rates\n");
      printf("    26th October 2004 /n ");
      printf("***********************************************************************\n");
           
/* Display the exchange rates and verify USdollar inputs for Australia, Canada, Great Britain, Europe, Mexico */
  /* Declaring variables for the five foreign nations as audcur, cadcur, gpdcur, eurcur, mxncur */            
 
      printf ("Exchange Rates For US $1.00\n\n");
      printf ("   Country      Rate\n");
      printf ("-------------------------------------------------------------------------------------------------------\n\n");
      printf ("Great Britain: %f%s\n",gpdcur,  British_unit);
      printf ("      Canada:  %f%s\n",cadcur,  Canadian_unit);
      printf ("      Europe:  %f%s\n",eurcur,  European_unit);  
      printf ("   Australia:  %f%s\n",audcur,  Australian_unit);
      printf ("      Mexico:  %f%s\n",mxncur,  Mexican_unit);
      printf(" Foreign currencies verify to one USdollar");
      printf ("The End\n");
      printf("Press Enter to end Program\n");
/*-------------------------------------------------------------------------------------------------------------------*/
}
        scanf("%f ,&value");
0
Comment
Question by:lclarius
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 4
12 Comments
 

Author Comment

by:lclarius
ID: 12427396
i change if(value <0.01 || value >1000.00)
now i'm getting Miracle C Compiler (r3.2), written by bts.
Compiling C:\Program Files\Miracle C\lisafour.c
main

C:\Program Files\Miracle C\lisafour.c: line 55: Parse Error, expecting `SEP'
'else  {   printf("***********************************************************************\n")'
aborting compile


plesase help me

i'm loosing it :)
#include <stdio.h>    
int main ()
{

         /*Declaring variables for five foreign nations, and there currencies
         for one USdollar and there NASD symbols, which are: */
         /* aud            Austrialia            1.40196  */
         /* cad            Canada             1.2754   */
         /* gpd            Great Britain         0.52434  */
         /* eur             Europe             0.812612 */
         /* mxn            Mexico             11.0425  */
                

// -----------------------------------------------------------------------------------------------------//

          float value, audcur, cadcur, gpdcur, eurcur, mxncur;
         
//------------------------------------------------------------------------------------------------------//

/* Variables for the denominations rate of the foreign currencies */
/* The variable names are representatives of foreign nations*/
     
          char British_unit[]="pounds";
          char Canadian_unit[]= "dollars";
          char European_unit[]= "euros";
          char Australian_unit[]="dollars";
          char Mexican_unit[]="pesos";
         
         
//-----------------------------------------------------------------------------------------------------//
           /*Display the value of the foreign exchange currency to one USdollar*/    
/*----------------------------------------------------------------------------------------------------- */
          scanf("%f ,&value"); /* for one USdollar */
          while (value !=  0.0)
          if(value <0.01 || value >1000.00)
      printf("Enter a dollar amount 0.01 to 1000.00 for all listed currencies to one USdollar");  
}
else
{  
 
      /*Display report title and date of conversion */

      printf("***********************************************************************\n");
      printf("  Currency Conversion Rates\n");
      printf("    26th October 2004 /n ");
      printf("***********************************************************************\n");
           
/* Display the exchange rates and verify USdollar inputs for Australia, Canada, Great Britain, Europe, Mexico */
  /* Declaring variables for the five foreign nations as audcur, cadcur, gpdcur, eurcur, mxncur */            
 
      printf ("Exchange Rates For US $1.00\n\n");
      printf ("   Country      Rate\n");
      printf ("-------------------------------------------------------------------------------------------------------\n\n");
      printf ("Great Britain: %f%s\n",gpdcur,  British_unit);
      printf ("      Canada:  %f%s\n",cadcur,  Canadian_unit);
      printf ("      Europe:  %f%s\n",eurcur,  European_unit);  
      printf ("   Australia:  %f%s\n",audcur,  Australian_unit);
      printf ("      Mexico:  %f%s\n",mxncur,  Mexican_unit);
      printf(" Foreign currencies verify to one USdollar");
      printf ("The End\n");
      printf("Press Enter to end Program\n");
/*-------------------------------------------------------------------------------------------------------------------*/
}
        scanf("%f ,&value");
}
0
 

Author Comment

by:lclarius
ID: 12429355
please give me a little help here - i'm getting
Miracle C Compiler (r3.2), written by bts.
line  91: String crosses a line: '%f"value);

C:\Program Files\Miracle C\helloworldlisadclariusweekfour.c: line 36: redeclaration of local
'float audcur = 1.40196'
aborting compile

I need help  

lclarius

/*-------------------------------------------------------------------------------
Purpose: US Dollar Currency Conversion

Version History: // PRO375, UOP //
Name: CurrencyConversionLisaClarius03.c
Number: 4 // Week four //
Date: 09/27/04
Student Programmer: Lisa Clarius
Version: IA Wk 2 // revised for Wk 4//
Purpose: Week Four IA coding
Date Revised: 10/26/04
Revised by: LDC
Instructor: Lon Hosford
-------------------------------------------------------------------------------*/


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

         /*Declaring variables for five foreign nations, and there currencies
         for one USdollar and there NASD symbols which are: */
         /* aud            Australia      1.40196  */
         /* cad            Canada             1.2754   */
         /* gpd            Great Britain   0.52434  */
         /* eur       Europe             0.812612 */
         /* mxn            Mexico             11.0425  */
                

// -----------------------------------------------------------------------------------------------------//

          float value, audcur, cadcur, gpdcur, eurcur, mxncur;
         
       /* Declaring and initializing currency conversion variables to their value */
      
          float audcur = 1.40196;
          float cadcur = 1.2754;
        float gpdcur = 0.52434;
        float eurcur = 0.812612;
        float mxncur = 11.0425;


         
//------------------------------------------------------------------------------------------------------//

/* Variables for the denominations rate of the foreign currencies */
/* The variable names are representatives of foreign nations*/
     
          char British_unit[]="pounds";
          char Canadian_unit[]= "dollars";
          char European_unit[]= "euros";
          char Australian_unit[]="dollars";
          char Mexican_unit[]="pesos";
         
         
//-----------------------------------------------------------------------------------------------------//
           /*Display the value of the foreign exchange currency to one USdollar*/    
/*----------------------------------------------------------------------------------------------------- */
          scanf("%f ,&value"); /* for one USdollar */
          while(value!=0)  
          if(value<0.01 || value>1000.00)

{
      printf("Enter a dollar amount 0.01 to 1000.00 for all listed currencies to one USdollar");  

}else
{  
 
      /*Display report title and date of conversion */

      printf("***********************************************************************\n");
      printf("  Currency Conversion Rates\n");
      printf("    26th October 2004 /n ");
      printf("***********************************************************************\n");
           
 /* Display the exchange rates and verify USdollar inputs for British, Canadian, European, Australian and Mexican */
 
      printf ("Exchange Rates For US $1.00\n\n");
      printf ("   Country      Rate\n");
      printf ("-------------------------------------------------------------------------------------------------------\n\n");
      printf ("Great Britain: %f%s\n",gpdcur*value,  British_unit);
      printf ("      Canada:  %f%s\n",cadcur*value,  Canadian_unit);  
      printf ("      Europe:  %f%s\n",eurcur*value,  European_unit);    
      printf ("   Australia:  %f%s\n",audcur*value,  Australian_unit);
      printf ("      Mexico:  %f%s\n",mxncur*value,  Mexican_unit);
      printf(" Foreign currencies verify to one USdollar");
      printf ("\n");
      printf("Press Enter to end Program\n");
/*-------------------------------------------------------------------------------------------------------------------*/

scanf('%f"value);
}
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 12429950
You used scanf function in wrong format in two places:
at first: scanf("%f ,&value");  
scanf take two or more parameters, change to scanf("%f" ,&value);
next: scanf('%f"value);    change to: scanf("%f" ,&value);

also you define float variables two times. one when in line:

float value, audcur, cadcur, gpdcur, eurcur, mxncur;
         
and other in:

float audcur = 1.40196;
float cadcur = 1.2754;
........
........

I comment first. The second is enough.

also I change the prompt from "Press Enter to End" to "Enter 0 to End" because you wait for 0 to end your loop.

// ==================================================


/*-------------------------------------------------------------------------------
Purpose: US Dollar Currency Conversion

Version History: // PRO375, UOP //
Name: CurrencyConversionLisaClarius03.c
Number: 4 // Week four //
Date: 09/27/04
Student Programmer: Lisa Clarius
Version: IA Wk 2 // revised for Wk 4//
Purpose: Week Four IA coding
Date Revised: 10/26/04
Revised by: LDC
Instructor: Lon Hosford
-------------------------------------------------------------------------------*/


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

         /*Declaring variables for five foreign nations, and there currencies
         for one USdollar and there NASD symbols which are: */
         /* aud          Australia     1.40196  */
         /* cad          Canada           1.2754   */
         /* gpd          Great Britain   0.52434  */
         /* eur      Europe           0.812612 */
         /* mxn          Mexico           11.0425  */


// -----------------------------------------------------------------------------------------------------//

            // float value, audcur, cadcur, gpdcur, eurcur, mxncur;

       /* Declaring and initializing currency conversion variables to their value */

            float audcur = 1.40196;
            float cadcur = 1.2754;
            float gpdcur = 0.52434;
            float eurcur = 0.812612;
            float mxncur = 11.0425;

            float value;

//------------------------------------------------------------------------------------------------------//

/* Variables for the denominations rate of the foreign currencies */
/* The variable names are representatives of foreign nations*/

            char British_unit[]="pounds";
            char Canadian_unit[]= "dollars";
            char European_unit[]= "euros";
            char Australian_unit[]="dollars";
            char Mexican_unit[]="pesos";


//-----------------------------------------------------------------------------------------------------//
          /*Display the value of the foreign exchange currency to one USdollar*/
/*----------------------------------------------------------------------------------------------------- */
            scanf("%f" ,&value); /* for one USdollar */
            while(value!=0)
                  if(value<0.01 || value>1000.00)
                  {
                        printf("Enter a dollar amount 0.01 to 1000.00 for all listed currencies to one USdollar");
                  } else {

                        /*Display report title and date of conversion */

                        printf("***********************************************************************\n");
                        printf("  Currency Conversion Rates\n");
                        printf("    26th October 2004 /n ");
                        printf("***********************************************************************\n");

            /* Display the exchange rates and verify USdollar inputs for British, Canadian, European, Australian and Mexican */

                        printf ("Exchange Rates For US $1.00\n\n");
                        printf ("   Country      Rate\n");
                        printf ("-------------------------------------------------------------------------------------------------------\n\n");
                        printf ("Great Britain: %f%s\n",gpdcur*value,  British_unit);
                        printf ("      Canada:  %f%s\n",cadcur*value,  Canadian_unit);
                        printf ("      Europe:  %f%s\n",eurcur*value,  European_unit);
                        printf ("   Australia:  %f%s\n",audcur*value,  Australian_unit);
                        printf ("      Mexico:  %f%s\n",mxncur*value,  Mexican_unit);
                        printf(" Foreign currencies verify to one USdollar");
                        printf ("\n");
                        printf("Enter 0 to end Program\n");
                  /*-------------------------------------------------------------------------------------------------------------------*/

                  scanf("%f", &value);
            }
}

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:lclarius
ID: 12429981
will do --- will let you know how it works out --- these are stupid  mistakes ........... hey with every mistake i'm learning
thanks million lclarius
0
 

Author Comment

by:lclarius
ID: 12430050


I'm getting an error on value ......... this is a nightmare for real

Miracle C Compiler (r3.2), written by bts.

C:\Program Files\Miracle C\helloworldlisadclariusweekfour.c: line 59: variable 'value' not found
'("%f",&value)'
aborting compile

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

         /*Declaring variables for five foreign nations, and there currencies
         for one USdollar and there NASD symbols which are: */
         /* aud            Australia      1.40196  */
         /* cad            Canada             1.2754   */
         /* gpd            Great Britain   0.52434  */
         /* eur       Europe             0.812612 */
         /* mxn            Mexico             11.0425  */
                

// -----------------------------------------------------------------------------------------------------//

        // Display  audcur, cadcur, gpdcur, eurcur, mxncur//
         
       /* Declaring and Intializing currency conversion variables to their values */
      
          float audcur = 1.40196;
          float cadcur = 1.2754;
        float gpdcur = 0.52434;
        float eurcur = 0.812612;
        float mxncur = 11.0425;


         
//------------------------------------------------------------------------------------------------------//

/* Variables for the denominations rate of the foreign currencies */
/* The variable names are representatives of foreign nations*/
     
          char British_unit[]="pounds";
          char Canadian_unit[]= "dollars";
          char European_unit[]= "euros";
          char Australian_unit[]="dollars";
          char Mexican_unit[]="pesos";
         
         
//-----------------------------------------------------------------------------------------------------//
           /*Display the value of the foreign exchange currency to one USdollar*/    
/*----------------------------------------------------------------------------------------------------- */
          scanf("%f" ,&value); /* for one USdollar */
          while(value!=0)  
          if(value<0.01 || value>1000.00)

{
      printf("Enter a dollar amount 0.01 to 1000.00 for all listed currencies to one USdollar");  

}else
{  
 
      /*Display report title and date of conversion */

      printf("***********************************************************************\n");
      printf("  Currency Conversion Rates\n");
      printf("    26th October 2004 /n ");
      printf("***********************************************************************\n");
           
 /* Display the exchange rates and verify USdollar inputs for British, Canadian, European, Australian and Mexican */
 
      printf ("Exchange Rates For US $1.00\n\n");
      printf ("   Country      Rate\n");
      printf ("-------------------------------------------------------------------------------------------------------\n\n");
      printf ("Great Britain: %f%s\n",gpdcur*value,  British_unit);
      printf ("      Canada:  %f%s\n",cadcur*value,  Canadian_unit);  
      printf ("      Europe:  %f%s\n",eurcur*value,  European_unit);    
      printf ("   Australia:  %f%s\n",audcur*value,  Australian_unit);
      printf ("      Mexico:  %f%s\n",mxncur*value,  Mexican_unit);
      printf(" Foreign currencies verify to one USdollar");
      printf ("\n");
      printf("Enter 0 to end \n");
/*-------------------------------------------------------------------------------------------------------------------*/

scanf("%f"value);
}
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 12430225
You must declare value also.
Place

float value;

statement where you define other variables in:

 /* Declaring and Intializing currency conversion variables to their values */
     
===>  [add]:  

  float value;

  float audcur = 1.40196;
  float cadcur = 1.2754;
  .....

also you have sybtax error in second scanf too:


scanf("%f"value);     [Change to ==>]     scanf("%f", value);


//-------------------

-FA



0
 

Author Comment

by:lclarius
ID: 12430312
I know i must sound so stupid here, I'm learning please don't get upset ....... sorry just learning
i'm getting this now Miracle C Compiler (r3.2), written by bts.

(null) Parse Error, expecting `'}''
''
aborting compile

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



         /*Declaring variables for five foreign nations, and there currencies
         for one USdollar and there NASD symbols which are: */
         /* aud            Australia      1.40196  */
         /* cad            Canada             1.2754   */
         /* gpd            Great Britain   0.52434  */
         /* eur       Europe             0.812612 */
         /* mxn            Mexico             11.0425  */
                

// -----------------------------------------------------------------------------------------------------//

        // Display  audcur, cadcur, gpdcur, eurcur, mxncur//
         
       /* Declaring and Intializing currency conversion variables to their values */

     float value;            float audcur = 1.40196;
                      float cadcur = 1.2754;
                    float gpdcur = 0.52434;
                    float eurcur = 0.812612;
                    float mxncur = 11.0425;
     
//------------------------------------------------------------------------------------------------------//

/* Variables for the denominations rate of the foreign currencies */
/* The variable names are representatives of foreign nations*/
     
                      char British_unit[]="pounds";
                     char Canadian_unit[]= "dollars";
                      char European_unit[]= "euros";
                      char Australian_unit[]="dollars";
                      char Mexican_unit[]="pesos";
         
         
//-----------------------------------------------------------------------------------------------------//
           /* Declare the foreign exchange currency value to one USdollar */    
/*----------------------------------------------------------------------------------------------------- */
          scanf("%f",value); /* for one USdollar */  
          while (value !=  0.0)
          if(value<0.01 || value>1000.00)

{
      printf("Enter a dollar amount 0.01 to 1000.00 for all listed currencies to one USdollar");  

}else
{  
 
      /*Display report title and date of conversion */

      printf("***********************************************************************\n");
      printf("  Currency Conversion Rates\n");
      printf("    26th October 2004 /n ");
      printf("***********************************************************************\n");
           
 /* Display the exchange rates and verify USdollar inputs for British, Canadian, European, Australian and Mexican */
 
      printf ("Exchange Rates For US $1.00\n\n");
      printf ("   Country      Rate\n");
      printf ("-------------------------------------------------------------------------------------------------------\n\n");
      printf ("Great Britain: %f%s\n",gpdcur*value,  British_unit);
      printf ("      Canada:  %f%s\n",cadcur*value,  Canadian_unit);  
      printf ("      Europe:  %f%s\n",eurcur*value,  European_unit);    
      printf ("   Australia:  %f%s\n",audcur*value,  Australian_unit);
      printf ("      Mexico:  %f%s\n",mxncur*value,  Mexican_unit);
      printf(" Foreign currencies verify to one USdollar");
      printf ("\n");
      printf("Enter 0 to end \n");
/*-------------------------------------------------------------------------------------------------------------------*/

 scanf("%f", value);

}
0
 

Author Comment

by:lclarius
ID: 12430418
please come back to me soon - i need help lclarius
0
 
LVL 14

Accepted Solution

by:
Farzad Akbarnejad earned 2000 total points
ID: 12430625
add close brace  (  } )  in the end of your program after second scanf statement:

     printf("Enter 0 to end \n");
/*-------------------------------------------------------------------------------------------------------------------*/

   scanf("%f", value);
  }      // <===               * This is for closing else section of if - else block
}


If your are using indent style you can reduce these type mistakes:


main()
{
    ....
    ....
    while (   )
        if  (  )
        {
             ....
             ....
        } else {
             ....
             ....
        }   // end of if block

}  // For end of main



-FA    
0
 

Author Comment

by:lclarius
ID: 12430648
thank you for coming back to me ... will implement changes and compile to see if all is ok
will let you know - your the greates FA :))))
0
 

Author Comment

by:lclarius
ID: 12430693
I could kiss you thank you so much -------- your a life saver :)))))))))))
 Miracle C Compiler (r3.2), written by bts.

Miracle C Compiler (r3.2), written by bts.
Linking object C:\Program Files\Miracle C\helloworldlisadclariusweekfour.obj,,C:\Program Files\Miracle C\helloworldlisadclariusweekfour.map,c:\Program Files\Miracle C\ccl.lib <exe.file>;
file 'c:\program files\miracle c\ccl.lib <exe.file>' failed to open for read in linker

Build completed


We are in business now ....... Many thanks and may you have a blessed night :)
0
 
LVL 14

Expert Comment

by:Farzad Akbarnejad
ID: 12431771
Glad to help you :-)

Thanks
-FA
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Introduction to Processes

604 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