我是c ++初学者,我想编写一个USD / EUR交换程序,对于输出,我想写:“您得到多少美元/欧分,但是我不知道如何,因为我有只输出美分。
double eur{0},usd{0},sum{0},kurs{1.14},x,c,d,y;
cout<<"Do you want change Euro or Dollar?"<<endl<<"a is for Euro in Dollar, b is for Dollar in Euro, put a oder b in: "<<endl;
char input = ' ';
cin>>input;
cout<<"Give the sum you want to exchange: ";
cin>>sum;
if (input == 'a'){
usd=sum;
x=usd*kurs;
y= x*100%100; (MODULO is not usable, error, why?)
cout<<"You get "<< x <<" dollar and " << y << "cents."
答案 0 :(得分:1)
您可以使用floor函数获取整数部分并将其从您的数字中减去。
Item.first.user.image_url(:original)
Item Load (1.5ms) SELECT `items`.* FROM `items` ORDER BY `items`.`id` ASC LIMIT 1
User Load (0.7ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
=> "https://xx.s3.ap-northeast-1.amazonaws.com/store/user/1/image/original-xx”
Item.first.user.id
(19.0ms) SET NAMES utf8mb4, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
Item Load (0.9ms) SELECT `items`.* FROM `items` ORDER BY `items`.`id` ASC LIMIT 1
User Load (0.8ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 1 LIMIT 1
=> 1