usingnamespacestd;classDepartment{protecte..."/>

成人学院中文字幕,国产午夜麻豆影院在线观看,久久男人免费视频,久久精品美女视频,www.福利视频,蜜桃一本色道久久综合亚洲精品冫,欧美三级视频

軟題庫 移動APP 掃碼下載APP 隨時隨地移動學習 培訓課程
試卷名稱 2010年上半年程序員考試下午真題試題(案例分析)
考試中心《2010年上半年程序員考試下午真題試題(案例分析)》在線考試
試卷年份2010年上半年
試題題型【分析簡答題】
試題內容

閱讀以下說明和C++代碼,將應填入 (n) 處的字句寫在答題紙的對應欄內。
【說明】
現需要統(tǒng)計某企業(yè)員工的月平均工資,即該企業(yè)本月發(fā)給員工的工資總和除以員工數。假設企業(yè)本月發(fā)給員工的工資總和為sumSalary,該企業(yè)的員工總數為employeeNumber,下面的程序代碼計算該企業(yè)員工本月的平均工資,其中需要處理employNumber為0的情況。 
【C++代碼】
#include <iostream>
using namespace std;
class Department{
protected:
float   average(float   x ,int  y)  {
if (y = =0) throw    (1);
return  x/y;
}
public:
void  caculate(void)  {
float sumSalary;
int    employeeNumber;
try {
     cout << "請輸入當月工資總和與員工數:" << end1;
     cin  >> sumSalary  >> employeeNumber;
     float  k=average(sumSalary,employeeNumber);
     cout  <<  "平均工資: "<<  k  <<  end1;
}
(2)(int e) {
if(e = =0) {
    cout << "請重新輸入當月工資總和與員工數 :" << end1;
    cin  >>  sumSalary  >>  employeeNumber;
    float k =average(sumSalary,employeeNumber);
    cout  <<  "平均工資: "<<  k  <<  end1;
  }
 }
}
};
 
void  main ( ) {
try  {
(3);
d.caculate ( );
}
(4)(int  e) {
if  (  e = = 0)
cout <<  "程序未正確計算平均工資! " << end1;
}

【問題 1】
程序運行時,若輸入的員工工資總和為6000,員工數為5,則屏幕輸出為:
請輸入當月工資總和與員工數:
6000 5
(5)
【問題 2】
若程序運行時,第一次輸入的員工工資總和為6000,員工數為0,第二次輸入的員工工資總和為0,員工數為0,則屏幕輸出為:
請輸入當月工資總和與員工數:
6000 0
(6)   
0 0
(7)


相關試題

推薦文章
合作網站內容