Solved

currency conversion

Posted on 2004-10-27
346 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
Question by:lclarius
    12 Comments
     

    Author Comment

    by:lclarius
    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
    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
    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
     

    Author Comment

    by:lclarius
    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


    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
    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
    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
    please come back to me soon - i need help lclarius
    0
     
    LVL 14

    Accepted Solution

    by:
    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
    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
    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
    Glad to help you :-)

    Thanks
    -FA
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: From Zero to Hero with Nodejs & MongoDB

    Interested in Node.js, but don't know where to start or how to learn it properly? Confused about how the MEAN stack pieces of MongoDB, Expressjs, Angularjs, and Nodejs fit together? Or how it's even possible to run JavaScript outside of the browser?

    Suggested Solutions

    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    This is about my first experience with programming Arduino.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    846 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

    7 Experts available now in Live!

    Get 1:1 Help Now