Solved

Currency conversion

Posted on 2004-04-28
10
897 Views
Last Modified: 2010-04-02
Write a C program to do currency conversion. The program will display a title "Currency Conversion," ask the user to enter the amount in US dollars, and then convert it into 5 foreign currencies. The program will then output the names of five currencies and their equivalents to US dollars. Use the exchange rates below.

1 Swiss Franc = 0.6072 US dollars
1 British Pound = 1.4320 US Dollars
1 Japanese Yen = 0.0081 US DOLLARS
1 Canadian Dollar = 0.6556 US Dollars
1 Euro                 = 0.8923 US Dollars
0
Comment
Question by:shnhutson
  • 3
  • 3
  • 2
10 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 10939787
And your problem is... What's the code you have?
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10939813
Homework???

We're not allowed to do your homework,
either post your attempt at the code,or tell us specifically where you are stuck,
We'll be glad to help.


0
 

Author Comment

by:shnhutson
ID: 10939849
I am stuck after I include < stdio.h>. How do I define the different currencies.
0
 
LVL 9

Accepted Solution

by:
ankuratvb earned 125 total points
ID: 10939897
Think what you have to do:

First,you need to get the dollar value from the user.Take a float.
float dollar;

Then,conversion requires multiplication with the values you have provided above.These are decimal values as well,so use float for them as well.
float euro=0.1234;//whatever your value,place here
//similarly for the other currencies as well.

Multiply the dollar with the conversion value and you have the converted value.

Use printf() to display the text and the converted value.
0
Free book by J.Peter Bruzzese, Microsoft MVP

Are you using Office 365? Trying to set up email signatures but you’re struggling with transport rules and connectors? Let renowned Microsoft MVP J.Peter Bruzzese show you how in this exclusive e-book on Office 365 email signatures. Better yet, it’s free!

 
LVL 9

Expert Comment

by:ankuratvb
ID: 10939998
Lets say you define euro as:
float euro=0.8923;

>The program will then output the names of five currencies and their equivalents to US >dollars.

1 USD=1/euro

Use printf() to print these values out for all the five currencies.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 10940123
Now are you doing the homework for him/her after all. Writing the code would have been a lot faster, about 12 lines would be enough, wouldn't it?

ShnHutson: do you have a good book on C? I have a very old Kernighan & Ritchie "The C Programming Language", and you can find a similar program on page 8 already! (Celsius-Fahrenheit conversion)
0
 

Author Comment

by:shnhutson
ID: 10944982
Thanks for the help, I don't have any books on C. Only the teacher's weekly notes. What you have posted helped me out the rut.
0
 

Author Comment

by:shnhutson
ID: 11055510
I accepted it because I pieced together some of the comments that were made. I was running out of time.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand recursion in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to use strings and some functions related to them in the C programming language.

863 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

25 Experts available now in Live!

Get 1:1 Help Now