• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 340
  • Last Modified:

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.
0
martinez1112
Asked:
martinez1112
  • 5
  • 4
  • 3
  • +2
1 Solution
 
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
Independent Software Vendors: 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!

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

Featured Post

Independent Software Vendors: 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!

  • 5
  • 4
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now