473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Need help finishing this C code for a currency conversion!

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. /*This line is standard input output, # is directive, include is keyword, and stdio.h is header file*/
  3.  
  4. #include<stdlib.h>
  5. /*This line is standard input output, # is directive, include is keyword, and stdlib.h is standard library defininition*/
  6.  
  7. #include<math.h>
  8. /*This line is standard input output, # is directive, include is keyword, and math.h is mathematical declarations*/
  9.  
  10. main (void)
  11. {
  12. int selectionNumbers;
  13. int n;
  14. int s;
  15. float EUR = 10.8474; /* Amount of Mexican Peso to one US Dollar */
  16. float CHF = 0.985; /* Amount of Canadian Dollar to one US Dollar*/
  17. float GPB = 0.697; /* Amount of Chiense Yuan to one US Dollar*/
  18. float CAD = 1.1136; /* Amount of Australian Dollar to one US Dollar*/
  19. float AUD = 0.710; /* Amount of European Euro to one US Dollar*/
  20. float money;
  21. float total;
  22. int choice;
  23.  
  24. while (choice != '5')  
  25. /*These lines are data declaration and initialization*/
  26.  
  27. printf("\n Currency Converter \n");
  28. printf("\n Enter the type of currency \n");
  29. printf("\n Please select the currecny you want to convert to USD \n");
  30. printf("\n Press 1 for PES \n");
  31. printf("\n Press 2 for CAD \n");
  32. printf("\n Press 3 for CHI \n");
  33. printf("\n Press 4 for AUS \n");
  34. printf("\n Press 5 for EUR \n");
  35. scanf("%d", &choice);
  36. if(choice== 0)
  37. printf("\n Enter the amount you want to convert to USD \n");
  38. scanf("%d", &total);
  39. switch(choice)
  40. {
  41. /*PES: Mexican Peso*/
  42. case 1:
  43. total = (choice * 10.8474);
  44. printf("\n The equivalant USD for %f of PES is %fn \n", &total, &choice);
  45. break;
  46.  
  47. /*CAD: Canaidan Dollar*/
  48. case 2:
  49. total = (choice * 0.985);
  50. printf("\n The equivalent USD for %f of CAD is %fn \n", &total, &choice);
  51. break;
  52.  
  53. /*CHI: Chiense Yuan*/
  54. case 3:
  55. total = (choice * 0.697);
  56. printf("\n The equivalent USD for %f of CHI is %fn \n", &total, &choice);
  57. break;
  58.  
  59. /*Aus: Austrillian Dollar*/
  60. case 4:
  61. total = (choice * 1.1136);
  62. printf("\n The equivalent USD for %f of AUS is %fn \n", &total, &choice);
  63. break;
  64.  
  65. /*EUR: Europen Euro*/
  66. case 5:
  67. total = (choice * 0.710);
  68. printf("\n The equivalent USD for %f of EUR is $fn \n", &total, &choice);
  69. break;
  70. printf("\n Thanks for using the Currency Converter Program \n");
  71. }/*end switch*/
  72.  
  73. }/*end main*/
Oct 22 '07 #1
7 3752
r035198x
13,262 8TB
#include<stdio.h>
/*This line is standard input output, # is directive, include is keyword, and stdio.h is header file*/

#include<stdlib.h>
/*This line is standard input output, # is directive, include is keyword, and stdlib.h is standard library defininition*/

#include<math.h>
/*This line is standard input output, # is directive, include is keyword, and math.h is mathematical declarations*/

main (void)
{
int selectionNumbers;
int n;
int s;
float EUR = 10.8474; /* Amount of Mexican Peso to one US Dollar */
float CHF = 0.985; /* Amount of Canadian Dollar to one US Dollar*/
float GPB = 0.697; /* Amount of Chiense Yuan to one US Dollar*/
float CAD = 1.1136; /* Amount of Australian Dollar to one US Dollar*/
float AUD = 0.710; /* Amount of European Euro to one US Dollar*/
float money;
float total;
int choice;

while (choice != '5')
/*These lines are data declaration and initialization*/

printf("\n Currency Converter \n");
printf("\n Enter the type of currency \n");
printf("\n Please select the currecny you want to convert to USD \n");
printf("\n Press 1 for PES \n");
printf("\n Press 2 for CAD \n");
printf("\n Press 3 for CHI \n");
printf("\n Press 4 for AUS \n");
printf("\n Press 5 for EUR \n");
scanf("%d", &choice);
if(choice== 0)
printf("\n Enter the amount you want to convert to USD \n");
scanf("%d", &total);
switch(choice)
{
/*PES: Mexican Peso*/
case 1:
total = (choice * 10.8474);
printf("\n The equivalant USD for %f of PES is %fn \n", &total, &choice);
break;

/*CAD: Canaidan Dollar*/
case 2:
total = (choice * 0.985);
printf("\n The equivalent USD for %f of CAD is %fn \n", &total, &choice);
break;

/*CHI: Chiense Yuan*/
case 3:
total = (choice * 0.697);
printf("\n The equivalent USD for %f of CHI is %fn \n", &total, &choice);
break;

/*Aus: Austrillian Dollar*/
case 4:
total = (choice * 1.1136);
printf("\n The equivalent USD for %f of AUS is %fn \n", &total, &choice);
break;

/*EUR: Europen Euro*/
case 5:
total = (choice * 0.710);
printf("\n The equivalent USD for %f of EUR is $fn \n", &total, &choice);
break;
printf("\n Thanks for using the Currency Converter Program \n");
}/*end switch*/

}/*end main*/
Moved from challenges forum to C forum.
And please make use of code tags when posting code.
Oct 22 '07 #2
sorry new in here and to programming any suggestions?
Oct 22 '07 #3
Meetee
931 Expert Mod 512MB
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. /*This line is standard input output, # is directive, include is keyword, and stdio.h is header file*/
  3.  
  4. #include<stdlib.h>
  5. /*This line is standard input output, # is directive, include is keyword, and stdlib.h is standard library defininition*/
  6.  
  7. #include<math.h>
  8. /*This line is standard input output, # is directive, include is keyword, and math.h is mathematical declarations*/
  9.  
  10. main (void)
  11. {
  12. int selectionNumbers;
  13. int n;
  14. int s;
  15. float EUR = 10.8474; /* Amount of Mexican Peso to one US Dollar */
  16. float CHF = 0.985; /* Amount of Canadian Dollar to one US Dollar*/
  17. float GPB = 0.697; /* Amount of Chiense Yuan to one US Dollar*/
  18. float CAD = 1.1136; /* Amount of Australian Dollar to one US Dollar*/
  19. float AUD = 0.710; /* Amount of European Euro to one US Dollar*/
  20. float money;
  21. float total;
  22. int choice;
  23.  
  24. while (choice != '5')
  25. /*These lines are data declaration and initialization*/
  26.  
  27. printf("\n Currency Converter \n");
  28. printf("\n Enter the type of currency \n");
  29. printf("\n Please select the currecny you want to convert to USD \n");
  30. printf("\n Press 1 for PES \n");
  31. printf("\n Press 2 for CAD \n");
  32. printf("\n Press 3 for CHI \n");
  33. printf("\n Press 4 for AUS \n");
  34. printf("\n Press 5 for EUR \n");
  35. scanf("%d", &choice);
  36. if(choice== 0)
  37. printf("\n Enter the amount you want to convert to USD \n");
  38. scanf("%d", &total);
  39. switch(choice)
  40. {
  41. /*PES: Mexican Peso*/
  42. case 1:
  43. total = (choice * 10.8474);
  44. printf("\n The equivalant USD for %f of PES is %fn \n", &total, &choice);
  45. break;
  46.  
  47. /*CAD: Canaidan Dollar*/
  48. case 2:
  49. total = (choice * 0.985);
  50. printf("\n The equivalent USD for %f of CAD is %fn \n", &total, &choice);
  51. break;
  52.  
  53. /*CHI: Chiense Yuan*/
  54. case 3:
  55. total = (choice * 0.697);
  56. printf("\n The equivalent USD for %f of CHI is %fn \n", &total, &choice);
  57. break;
  58.  
  59. /*Aus: Austrillian Dollar*/
  60. case 4:
  61. total = (choice * 1.1136);
  62. printf("\n The equivalent USD for %f of AUS is %fn \n", &total, &choice);
  63. break;
  64.  
  65. /*EUR: Europen Euro*/
  66. case 5:
  67. total = (choice * 0.710);
  68. printf("\n The equivalent USD for %f of EUR is $fn \n", &total, &choice);
  69. break;
  70. printf("\n Thanks for using the Currency Converter Program \n");
  71. }/*end switch*/
  72.  
  73. }/*end main*/
  74.  
So whare is the problem? You encounter with any error here?
Oct 22 '07 #4
So whare is the problem? You encounter with any error?
It loop Currency Conversion while running. Program is supposed to allow user to choice which currency to convert and take input until user decides to exit
[#include<stdio.h>
/*This line is standard input output, # is directive, include is keyword, and stdio.h is header file*/

#include<stdlib.h>
/*This line is standard input output, # is directive, include is keyword, and stdlib.h is standard library defininition*/

#include<math.h>
/*This line is standard input output, # is directive, include is keyword, and math.h is mathematical declarations*/

main (void)
{
int selectionNumbers;
int n;
int s;
float PES = 10.8474; /* Amount of Mexican Peso to one US Dollar */
float CAD = 0.985; /* Amount of Canadian Dollar to one US Dollar*/
float CHI = 0.697; /* Amount of Chiense Yuan to one US Dollar*/
float AUD = 1.1136; /* Amount of Australian Dollar to one US Dollar*/
float EUR = 0.710; /* Amount of European Euro to one US Dollar*/
float money;
float total;
int choice;
while (choice != '5')
/*These lines are data declaration and initialization*/

printf("\n Currency Converter \n");
printf("\n Enter the type of currency \n");
printf("\n Please select the currecny you want to convert to USD \n");
printf("\n Press 1 for PES \n");
printf("\n Press 2 for CAD \n");
printf("\n Press 3 for CHI \n");
printf("\n Press 4 for AUS \n");
printf("\n Press 5 for EUR \n");
scanf("%d", &choice);
if(choice== 0)
printf("\n Enter the amount you want to convert to USD \n");
scanf("%d", &total);
switch(choice)
{
/*PES: Mexican Peso*/
case 1:
total = (choice * 10.8474);
printf("\n The equivalant USD for %f of PES is %fn \n", &total, &choice);
break;

/*CAD: Canaidan Dollar*/
case 2:
total = (choice * 0.985);
printf("\n The equivalent USD for %f of CAD is %fn \n", &total, &choice);
break;

/*CHI: Chiense Yuan*/
case 3:
total = (choice * 0.697);
printf("\n The equivalent USD for %f of CHI is %fn \n", &total, &choice);
break;

/*Aus: Austrillian Dollar*/
case 4:
total = (choice * 1.1136);
printf("\n The equivalent USD for %f of AUS is %fn \n", &total, &choice);
break;

/*EUR: Europen Euro*/
case 5:
total = (choice * 0.710);
printf("\n The equivalent USD for %f of EUR is $fn \n", &total, &choice);
break;
printf("\n Thanks for using the Currency Converter Program \n");
}/*end switch*/

}/*end main*/]
Oct 22 '07 #5
Meetee
931 Expert Mod 512MB
I am still not getting your problem!! I do not find anything wrong in this code. It asks for choice and amount and prints conversion.

Regards
Oct 22 '07 #6
cdev
2
Here is the working code of currency converter:

/******* There were some basic mistakes done like adding & in the print statement and mistake were in the computation. Also comment the while loop statement....Suggest you to compare this code with yours !! *********/
spoonfeeding removed. Please post issues with the code, don't just fix it for the OP (then nothing is learned).

Also, please use code tags

sicarie
Oct 22 '07 #7
Sorry about the code tags did not understand but I got it now. I donot see your suggestions, should I remove the & in the printf.




Here is the working code of currency converter:

/******* There were some basic mistakes done like adding & in the print statement and mistake were in the computation. Also comment the while loop statement....Suggest you to compare this code with yours !! *********/
spoonfeeding removed. Please post issues with the code, don't just fix it for the OP (then nothing is learned).

Also, please use code tags

sicarie
Oct 22 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: techy techno | last post by:
hii Experts..!! I need someone to tell me where I can get a Currency Converter like http://cconv.textor.com please can someone tell me where I can get it I need it for free + I dont need...
2
by: Willing 2 Learn | last post by:
I'm still having trouble getting my program to do arithmetic in cents(keeping all #'s) then convert the answer in a format of dollars & cents. The main program should add, subtract, scalar...
1
by: Vishal | last post by:
Hello, how can we convert a value from one currency to another currency in vb.net? Is that possible? I dont want to use any hardcoded value for the exchange rate. I wont to get it online and do...
3
by: Shapper | last post by:
Hello, I am working on an ASP.NET/VB web site. I have several links including menu links. Considerer a want to load a page named page.aspx. I can do it using javascript. Or using this code:...
3
by: Josh | last post by:
I am writing a program where the user inputs currency in US dollars. I want the program to only accept valid currency input, converting the string into the proper type of variable (double?), and...
11
by: Adrian | last post by:
Hi I want to use the following declarations but vb dotnet keeps complaining that currency can't be used because it private ? I have tried it in a module and in the declaration pare same error!...
4
by: david.w.anderson1 | last post by:
This is a homework assignment. The code works but does not "catch" all the improper input. The requirement is to be able to accept one input currency, which is error checked as a valid entry, and...
2
by: sck10 | last post by:
Hello, I have a SQL Server 2K table with a field set to currency. When I try to insert or update a FormView, I get the following error: Disallowed implicit conversion from data type nvarchar...
18
by: Boris Yeltsin | last post by:
OK, I have a database table, it has prices of products in it, like so: ProductPrice MONEY ProductIsoCurrencyCode CHAR(3) Now, both CultureInfo and RegionInfo have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.