货币转换器C代码编程 [英] currency converter C code programming

查看:129
本文介绍了货币转换器C代码编程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

外币转换器C代码编程.
用C编写一个计算机程序,该程序将要求用户输入一个数字,该数字表示他/她想兑换成马来西亚林吉特(MYR)的外币数量.您的程序是交互式的,因此应能满足用户的任何输入量.
转换器C代码程序中涉及的外币是新加坡元(SGD),美元(USD),英镑(GBP)和欧元(EUR).
您的程序应输出外币换算,显示对于用户输入的金额,每种类型的外币可以得到多少.
以下是2010年12月6日的最新货币汇率.

1 SGD = 2.4047MYR
1 USD = 3.13400 MYR
1 GBP = 4.93304 MYR
1 EUR = 4.18329 MYR

该程序应将SGD,USD,GBP和EUR读取为浮点数.使用float代表MYR的金额.使用格式代码%.2f以两位十进制数字显示输出.
使用#define为有意义的常量赋予有意义的名称.特别是,应使用#define为MYR和SGD,USD,GBP和EUR之间的关系命名,而不是直接将其写入程序的表达式中.
在本练习中,您不得使用条件语句或循环(如果有,为,等).只能使用输入和输出以及赋值语句来编写程序.

Foreign currency converter C code programming.
Write a computer program in C which will request the user to enter a number representing the amount of foreign currency he/she would like to exchange to Malaysia Ringgit (MYR). Your program is interactive and so should work for any input amount from the user.
The foreign currencies which involve in your converter C Code program are Singapore Dollar (SGD), US Dollar (USD), Great Britain Pound (GBP) and Euro (EUR).
Your program should output the foreign currency conversion, showing how much of each type of foreign currency can be obtained for the amount the user enters.
Below is the latest currency rate as per 6th December 2010.

1 SGD = 2.4047MYR
1 USD = 3.13400 MYR
1 GBP = 4.93304 MYR
1 EUR = 4.18329 MYR

The program should read the SGD, USD, GBP and EUR as float. Use float to represent the amount in MYR. Use the formatting code %.2f to display the outputs in two decimal digits.
 Use #define to give meaningful names to significant constants. In particular, the relationships between MYR and SGD, USD, GBP and EUR should be given names using #define, not written directly into expressions in your program.
 You may not use conditional statements or loops (if, while, for, etc.) in this lab exercise. The program can be written using only input and output plus assignment statements.

推荐答案

如果您要张贴作业,请至少尝试使其看起来像您拥有的作业试图自己做点什么!

我们不做您的作业:这是有原因的.在这里,您可以考虑自己被告知的内容,并尝试理解它.也可以在那里帮助您的导师识别您的弱点,并将更多的注意力放在补救措施上.

自己尝试,或学习魔语:您要用它炸薯条吗?"
If you are going to post your homework, at least try to make it look like you have attempted to do something yourself!

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, or learn the Magic Words: "Do you want fries with that?"


这篇关于货币转换器C代码编程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆