• C

Currency conversions program

Hello I'm doing a program for a homework. I'm using Miracle C compiler.
this is what I have to do;
Write a C program that displays the title "Currency Conversion," and then write the names of five currencies and their equivalents to the US dollar. The conversions are hard coded equations.

and this is what I have

#include <stdio.h>

main()
{

//variable declarations for constant conversion equations
const float f_const_USD = 1.00; //1.00 USD = 1.00 United States Dollar
const float f_const_EUR = 0.569280; //1.00 USD = 0.9223357 Europe EURO
const float f_const_JPY = 1.15940; //1.00 USD = 118.218 Japan Yen
const float f_const_MXN = 10.7010; //1.00 USD = 10.79889 Mexico Pesos
const float f_const_RUB = 115.860; //1.00 USD = 31.9191 Russian Ruble
const float f_const_SEK = 7.75760; //1.00 USD = 8.48792 Swedish Kronor

//print title of program
printf("\nCurrency Conversion");
printf("\n");

//print currency conversions
printf("\nOne United States Dollar Equals...");
printf("\n%f.2,f_const_EUR Europe EURO");
printf("\n%f.2,f_const_JPY Japan Yen");
printf("\n%f.2,f_const_MXN Mexico Pesos");
printf("\n%f.2,f_const_RUB Russian Ruble");
printf("\n%f.2,f_const_SEK Swedish Kronor");
printf("\n\nI Did It Again!");


}

But I have this;

Miracle C Compiler (r3.2), written by bts.
Compiling C:\Program Files\Miracle C\Currency Convertion Program.c
main

C:\Program Files\Miracle C\Currency Convertion Program.c: line 17: Parse Error, expecting `','' or `SEP'
'float f_const_USD = 1.00'
aborting compile

What I have to do I need help.
martinez1112Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rajeev_devinCommented:
Looks OK to me.
0
rajeev_devinCommented:
Just prefix f after each float literal to remove warnings.

const float f_const_USD = 1.00f;
const float f_const_EUR = 0.569280f;
const float f_const_JPY = 1.15940f;
const float f_const_MXN = 10.7010f;
const float f_const_RUB = 115.860f;
const float f_const_SEK = 7.75760f;
0
cwwkieCommented:
Miracle c does not accept the const keyword;

float f_const_USD = 1.00; //1.00 USD = 1.00 United States Dollar
float f_const_EUR = 0.569280; //1.00 USD = 0.9223357 Europe EURO
float f_const_JPY = 1.15940; //1.00 USD = 118.218 Japan Yen
float f_const_MXN = 10.7010; //1.00 USD = 10.79889 Mexico Pesos
float f_const_RUB = 115.860; //1.00 USD = 31.9191 Russian Ruble
float f_const_SEK = 7.75760; //1.00 USD = 8.48792 Swedish Kronor
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

rajeev_devinCommented:
Another thing, I don't knoiw whether Miracle C compiler supports const.
Old C compilers don't support const. Remove const and see whether it works.
0
rajeev_devinCommented:
Ooops I should have refreshed the question :-)
0
cwwkieCommented:
martinez1112,
there are more problems in your code. But first try to find it yourself.

rajeev_devin,
I think we almost posted the comment at the same time. But I was first :-)
0
rajeev_devinCommented:
>> I think we almost posted the comment at the same time. But I was first :-)
Yes I agree
0
Kelvin_KingCommented:
Check your printf statements also.

the syntax is:

http://ou800doc.caldera.com/en/SDK_tools/P_printfStatement.html
0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
http://www.devboxforums.com/printthread.php?t=2058

same question with solution. Great.
0
martinez1112Author Commented:
I start all over again and can do everytihng, but I still can't figure out why instead of every convertion it is giving me the last one?
any more help?


#include <studio.h>

main()
{
/*variable declarations for conversion equations*/
float f_USD = 1.00; //1.00 USD = 1.00 United States Dollar
float f_EUR = 0.569280; //1.00 USD = 0.9223357 Europe EURO
float f_JPY = 1.15940; //1.00 USD = 118.218 Japan Yen


//print title of program
printf("\nCurrency Conversion");
printf("\n");

//print currency conversions
printf("\nOne United States Dollar Equals...");
printf("\n");
printf("\n%f_EUR\tEurope EURO");
printf("\n");
printf("\n%f_JPY\tJapan Yen");
}
0
cwwkieCommented:
As noted before, your printf syntax is wrong.

Example:

float value=1.23;
printf("value=%f\n", value);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
martinez1112Author Commented:
in this

Value will be

float f_USD = 1.00;


so it will be

print("float f_USD=%f\n",USD);

or

print("1.00=%f\n",USD);

0
martinez1112Author Commented:
I did it.


#include <stdio.h>

main()
{
/*variable declarations for conversion equations*/
float USD = 1.00; //1.00 USD = 1.00 United States Dollar
float EUR = 0.569280; //1.00 USD = 0.9223357 Europe EURO
float JPY = 1.15940; //1.00 USD = 118.218 Japan Yen


//print title of program
printf("\nCurrency Conversion");
printf("\n");

//print currency conversions
printf("\nOne United States Dollar Equals...");
printf("\n");
printf("EUR=%f\n",EUR);
printf("\n");
printf("JPY=%f\n",JPY);
}

Thanks to the help of everyone.  now I just neet to add 3 more currency
wow.
0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
but i think i had clearly pointed you to the link which has same program as above?????

http://www.devboxforums.com/printthread.php?t=2058

0
cwwkieCommented:
> I did it.

Great, if you need more help, just let me know.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.