2016-10-21 3 views
-2

こんにちは私は給与と仕事のパフォーマンスを与えられたときに従業員のボーナスを計算するプログラムを作ろうとしています。私はそれを私の宿題の一部である私の機能を維持する必要があります。問題の内容に関するガイダンスをお寄せくださいC++は給与を計算しています

#include <iostream> 
using namespace std; 
double bonus(double salary,int a); 
int main() 
{ 
    double salary; 
    enum jobp{poor = 0,average = 1,good = 2}; 
    jobp performance; 
    int a = performance; 
    cout<<"Enter your salary and job performance (as a 0 for poor,1 for average and 2 for good)s$ 
    cin>>salary>>a; 
    bonus(salary,a); 
    cout<<"your bonus is "<<bonus; 
    return 0; 
} 
double bonus(double salary, int a) 
{ 
    double bonus; 
if (a == 2) 
{ 
    double c; 
    c = .10; 
    bonus = salary * c; 
    return bonus; 
} 
else if (a == 1) 
{ 
    double b; 
    b = .05; 
    bonus = salary * b; 
    return bonus; 
} 
else 
{ 
    return 0; 
} 
} 
+0

ボーナス関数は値を返します。そこから始めたいと思うかもしれません。 –

答えて

0

こんにちは、これはあなたの問題を解決するのに役立ちます。これに

cout<<"Enter your salary and job performance (as a 0 for poor,1 for average and 2 for good)s$ 
cin>>salary>>a; 
bonus(salary,a); 
cout<<"your bonus is "<<bonus; 

:この 変更

cout << "Enter your salary and job performance (as a 0 for poor,1 for average and 2 for good)" <<endl; 
cin >> salary >> a; 
cout << "your bonus is " << bonus(salary, a); 
0

キャッチが返さボーナス

#include <iostream> 
using namespace std; 
double bonus(double salary,int a); //this is for function right? 
int main() 
{ 
    double salary; 
    double bonus; //create a variable for bonus 
    enum jobp{poor = 0,average = 1,good = 2}; 
    jobp performance; 
    int a = performance; 
    cout<<"Enter your salary and job performance (as a 0 for poor,1 for average and 2 for good)s$ 
    cin>>salary>>a; 
    bonus = bonus(salary,a); //catch the return 
    cout<<"your bonus is "<<bonus; 
    return 0; 
} 
0

の値が個別に給与や性能を入力するようにユーザを持つようにしてください。

cout << "Please enter your salary: " << endl; 
cin >> salary; 
cout "Please job performance (as a 0 for poor,1 for average and 2 for good)" << endl; 
cin >> a; 
関連する問題