首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

这好像很古老的一样。不知道这一个语句啥意思的呢解决方案

2012-04-25 
这好像很古老的一样。不知道这一个语句啥意思的呢#includeiostreamusing namespace stdstruct CDAccount

这好像很古老的一样。不知道这一个语句啥意思的呢
#include<iostream>
using namespace std;
struct CDAccountV1//表示银行存款单结构;
{
double balance;
double interestRate;
int term;//存款期限用月份表示;
};
void getData(CDAccountV1&theAccount);//执行结构体的引用;
int main()
{
CDAccountV1 account;//结构体声明一个变量account;
getData(account);
double rateFraction,interest;
rateFraction=account.interestRate/100.0;
interest=account.balance*(rateFraction*(account.term/12.0));
account.balance=account.balance+interest;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);//这前面三句怎样解释啊不知道是啥;cout。setf(ios:fixed) cout.setf(ios::showpoint);
cout<<"when you CD matures in"
<<account.term<<"months\n"
<<"it will have a balance of$"
<<account.balance<<endl;
return 0;

}
void getData(CDAccountV1& theAccount)
{

cout<<"Enter account balance:$";
cin>>theAccount.balance;
cout<<"Entet account interest rate:";
cin>>theAccount.interestRate;
cout<<"Enter thr number of months until maturith:";
cin>>theAccount.term;

}


[解决办法]
cout.setf(ios::fixed)——用定点格式显示浮点数;
 cout.setf(ios::showpoint)——显示浮点数小数点后的0;
 cout.precision(2)——设置精确度为2位并返回上一次的设置
[解决办法]
http://www.cplusplus.com/reference/iostream/ostream/

楼主有什么不懂 不清楚 不会用的都问上面的链接吧 也比搜索的快 而且还标准

http://www.cplusplus.com/reference/iostream/ios_base/setf/

热点排行