page160

来源:互联网 发布:python 2.7.11 编辑:程序博客网 时间:2024/05/16 09:49

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

//律师事务所计费程序

#include "stdafx.h"
#include <iostream>
using namespace std ;

const double RATE = 150.00; //每刻钟收费的金额

double fee(int hours_worked , int minutes_worked);
//返回hours_worked小时又minutes_worked分钟的法律服务费

 

int _tmain(int argc, _TCHAR* argv[])
{
 int    hours , minutes ;
 double bill;

 cout << " welcome to the  offices of \n"
  << " Dewey , Cheatham , and Howe .\n "
  << " The law office with a heart .\n "
  << " Enter the hours and minutes  "
  << " of your consultation:\n";
 cin >> hours >> minutes;

 bill = fee (hours, minutes);

 cout.setf(ios::fixed);
 cout.setf(ios::showpoint);
 cout.precision(2);
 cout << " FOr " << hours << " hours and " << minutes
  << " minutes , your bill is  $ " << bill << endl ;

 cin >> hours;
 return 0;
}


double fee(int hours_worked , int minutes_worked)
{
 int quarter_hours;

 minutes_worked = hours_worked*60 + minutes_worked;
 quarter_hours = minutes_worked/15;
 return (quarter_hours * RATE);


}

原创粉丝点击