// page131.cpp : 定义控制台应用程序的入口点。
//C++面向对象程序设计
//根据用户的预算,计算可以购买多大的狗食
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
const double CONST_PER_SQ_FT = 10.50;
double budget , area ,length_side ;
cout << " Enter the amount budgeted for your dog house $ ";
cin >> budget ;
area = budget/CONST_PER_SQ_FT ;// 计算面积
//cout << area;
length_side = sqrt( area);//取平方根
cout.setf(ios::fixed);//格式化输出
cout.setf(ios::showpoint);
cout.precision(2);
cout << " For a price of $" << budget << endl
<< " I can build you a luxurious square dog house \n"
<< " that is " << length_side
<< " feet on each side .\n";
cin >> budget ;
return 0;
}
----------------------- 上传不了图-----------无图无真相