TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
veronica.colacci
NA
5
0
Brand New to C - HELP!!
Oct 4 2004 8:00 AM
I have only started learning C for about one week and we already have a program which we need to code, and of which I am so very confused - please help me. The following is what I need: Write a C program that displays a title, "Currency Conversion," and then write the names of five currencies and their equivalents to ONE (1.0) US dollar. The conversions are hard coded equations. Insert comments in the program to document the program internally. This is what I have so far: #include
int main(void) { printf("Currency Conversion.\n"); printf("\n\n"); printf("Conversion rates as of Sept. 30, 2004.\n"); Now here is what I don't know how to code. I have to hardcode the equations of the conversion rates - so Euro (EUR) Euro (the exchange rate is)1.2422 (divided by) /1 US Dollar = 0.8050 Canada (CAD) Canadian (rate is) 0.7912 / 1 US dollar = 1.2634 China (CNY) Chinese Renminbi (rate) 0.1208 / 1 US dollar = 8.2781 Japan (JPY) Japanese Yen (rate) 0.0091 / 1 US dollar = 110.180 Sweden (SEK) Swedish Krona (rate) 0.1373 / 1 US dollar = 7.2833 These are more instructions passed on to us because there were so many complaints but I am still confused: Your assignment must conform to these instructions. Here is a short skeleton of what the program should look like. This may help you get started. I'm ordering things in the order that your program should have them in order to help you get started laying out your own version. You will have to fill in the details #include statement(s) are first Start main program (i.e. void main() ) declare variables (5 of these will hold the 5 currency conversion rates. 5 other ones will hold the amount's of foreign currency, and you will also need a "dollars" variable. You may need more variables depending on how you write your program.) initialize variables as appropriate Hard coded equations (5) for calculating the amount of foreign currency that equals 1.0 US dollars. output statements to output the results. end of the program. Now, for the hard coded equations part. It should look something like this. roubles=conversionfactor*dollars; If you use the correct conversion factor then the variable roubles should hold the number of roubles that are equivalent to 1.0 US Dollars. This variable is then used in your output statement. You of course need to do this for 5 currencies. You will have 5 currency variables and 5 conversion factor variables. A common mistake is to use the wrong conversion factors (i.e. the one that gives numbers of dollars for 1.0 rouble). Some of you may ask, since this is such a simple program why can't you just write the output statements with the answers as hard coded numbers and skip the equation part? The answer is you will have to use equations such as this in the later assignments, so this is getting you ready. This first program will be modified to get your second program, etc.. Any assistance would be greatly appreciated and I thank you so much - ahead of time...... Regards, Julia
Reply
Answers (
4
)
DateTime years
controling a control from different form