Link to home
Start Free TrialLog in
Avatar of martinez1112
martinez1112

asked on

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.
Avatar of rajeev_devin
rajeev_devin

Looks OK to me.
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;
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
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.
Ooops I should have refreshed the question :-)
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 :-)
>> I think we almost posted the comment at the same time. But I was first :-)
Yes I agree
Check your printf statements also.

the syntax is:

http://ou800doc.caldera.com/en/SDK_tools/P_printfStatement.html
Avatar of Siva Prasanna Kumar
http://www.devboxforums.com/printthread.php?t=2058

same question with solution. Great.
Avatar of martinez1112

ASKER

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");
}
ASKER CERTIFIED SOLUTION
Avatar of cwwkie
cwwkie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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);

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.
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

> I did it.

Great, if you need more help, just let me know.