[1].[文件] Text1.cpp ~ 896B    下载(24) 跳至 [1]

#include<iostream>
using namespace std;

class payroll
{
   private:
	  float Workhours;
	  float perHPay;
   public:
	    /*payroll(float m=25,float n)
		{
		
		Workhours=m;
	    perHPay=n;26
		}*/
	 float  getweekpay();
	 void setWorkhours(float h,float m)
	 {
		Workhours=h;
         perHPay=m;
	 }
	~payroll()
	{
	};	
};
float payroll::getweekpay()
{
	  return(Workhours*perHPay);
 }
int main()
{
	payroll  a[10];
	int i;
	float hours,perhpay;
	for(i=0;i<10;i++)
	{
         cout<<"请输入第"<<i+1<<"个雇员的工作小时数"<<endl;
	     cin>>hours>>perhpay;
		 if(hours>60)
		 {
			 cout<<"请重新输入时间,一周的累\n5计工作时间不得超过60小时"<<endl;
		   //exit(0);
			 //break;
			 int t;
             t=i+1;
			 t=i;
		 }
		 else
		 {
	        a[i].setWorkhours(hours,perhpay);
		    cout<<"总收入为"<<a[i].getweekpay();
		 }
	}
	return 0;
}