我创建了一个程序,将实数转换为美元,并且浮点变量不正确[关闭]

问题描述 投票:-3回答:1

我创建了一个程序,将真实(巴西硬币)转换为美元,硬币是4位数,浮动变量更多:

#include <iostream>

using namespace std;

int main(int nNumberofArgs, char* pszArgs[]){
float fReal;
cout << "enter the cash in real: R$:";
cin >> fReal;
float fDollar = fReal / 3.90;
cout << "your cash in dollar(s): " << fDollar << endl; // Here i want 
//:.2f(from python) to the dollar value
cout << "Press enter to continue..." << endl;
cin.ignore(10, '\n');
cin.get();
return 0;
}
c++
1个回答
0
投票
std::cout << std::setprecision(2)<< fDollar<<'\n';
© www.soinside.com 2019 - 2024. All rights reserved.