page199

来源:互联网 发布:晨讯资源网源码 编辑:程序博客网 时间:2024/06/06 06:58

// page199.cpp : 定义控制台应用程序的入口点。
//C++ 面向对象程序设计

//get_input 函数的驱动程序

#include "stdafx.h"
#include <iostream>

void get_input(double& cost , int& turnover);
// 前条件:用户准备好输入正确的值
//后条件:cost的值设为一件商品的批发价
//turnover的值设为商品预计售出的天数


int _tmain(int argc, _TCHAR* argv[])
{
 using namespace std ;
 double wholesale_cost ;
 int sheil_time ;
 char ans ;

 cout.setf(ios::fixed);
 cout.setf(ios::showpoint);
 cout.precision(2);
 do
 {
  get_input(wholesale_cost  , sheil_time);
  cout << " wholesale_cost cost id now $"
   << wholesale_cost << sheil_time;
  cout << " Days unit sold is now "
   << sheil_time << endl ;

  cout << " Test again ?"
   << " (type y for yes or n for no ):";
  cin >> ans ;
  cout << endl ;
 }while( ans == 'y' || ans == 'Y');

 cin >> ans ;
 return 0;
}


//使用iostream
void get_input(double& cost , int& turnover)
{
 using namespace std ;
 cout << " Enter the wholesale cost of item: $";
 cin >> cost ;
 cout << " Enter the expected namber of days until sold: ";
 cin >> turnover ;

 

}

 

 

 


 

原创粉丝点击