java将五元换成1元5角_C,一个代码来获得一笔钱转换成四分之一,硬币,镍币,便士[关闭]...

该代码无法正常工作!我是C和我的新任务,编写一个从用户获取 Value 的代码(金额),然后将其转换为“季度= 25美分,硬币= 10美分,镍币= 5美分,便士= 1美分”所以例如当我输入值7.47我应该得到29季度,2角钱,0镍,2便士等...我的问题是,我已经尝试了很多值,它工作得很好,但当我尝试的 Value 9.53我应该得到38个季度,0角钱,0个镍币和3个便士但是我得到38个季度,0角钱,0个镍币和2个便士当我尝试8.53时会发生同样的错误,但是当我尝试6.53,5.53 .4.53时它的工作原理好 !!我现在很困惑,所以请帮助!!

`#include

using namespace std;

int main()

{

double money, c_money, quarters, dimes, nickels, pennies, remainder; char response;

new_input:

cout << " Enter the amount of money to be converted : " << endl;

cin >> money;

while (money < 0)

{

cout << " Invalid input , please enter a non-negative value " << endl;

cin >> money;

}

c_money = money * 100;

quarters = (int)c_money / 25;

remainder = (int)c_money % 25;

dimes = (int)remainder / 10;

remainder = (int)remainder % 10;

nickels = (int)remainder /5;

remainder = (int)remainder % 5;

pennies = (int)remainder ;

cout << endl;

cout << " The amount of money entered could be represented as : " << endl;

cout << "*****************************************************" << endl;

cout <

cout <

cout <

cout <

cout << "Do you want to enter more values ?? type , y or n and press Enter ! " << endl;

cin >> response;

if (response == 'y')

{

goto new_input;

}

else { cout << " Thanks for using our app !! " << endl << endl; }

return 0;

}`

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值