私は次のコードでエラーを修正するのに役立つ助けが必要です。主な機能は、働いた時間を受け取ってから、適切な時給を適用します。VOIDコードがグロスペイメントで働くのに役立つ
#include <iostream>
#include <iomanip>
using namespace std;
//function prototype
void getGrossPay(int regular,
int &timeAndHalf,
int &doubleTime);
int main()
{ //variables
const int REG_RATE = 10;
const int TIME_HALF = 15;
const int DOUB_TIME = 20;
int hoursWorked = 0;
cout << "Please enter your hours worked(press -1 to quit): ";
cin >> hoursWorked;
getGrossPay(regular, timeAndHalf, doubleTime);
while (hoursWorked != -1);
{
if(hoursWorked >=1 && hoursWorked <=37)
{
getGrossPay(regular);
cout << "Your gross pay is: $ (press -1 to exit)" << regular << endl;
cout << "Please enter your hours worked(press -1 to quit): ";
cin >> hoursWorked;
}
else
if (hoursWorked >=38 && hoursWorked <=50)
{
getGrossPay(timeAndHalf);
cout << "your gross pay is: $(press -1 to exit)" << timeAndHalf << endl;
cout << "Please enter your hours worked(press -1 to quit): ";
cin >> hoursWorked;
}
else
if (hoursWorked >=50)
{
getGrossPay(doubleTime);
cout << "your gross pay is: $(press -1 to exit)" << doubleTime << endl;
cout << "Please enter your hours worked(press -1 to quit): ";
cin >> hoursWorked;
}//end if
}//end while
}// end of main function
//****function definitions*****
void getGrossPay(int regular,
int &timeAndHalf,int &doubleTime)
{
regular = hoursWorked * REG_RATE;
timeAndHalf = hoursWorked * TIME_HALF;
doubleTime = hoursWorked * DOUB_TIME;
} // end getGrossPay function
はい、これはクラス用です。いいえ、私は答えがほしくない。
疑い問題:
- マイ無効な構文文が適切に私の変数は違法void関数
任意およびすべてから呼び出されている
EDIT:
だから、 "修正" このコードは基本的にフリーズし、実行可能に私を取得します。
無効getGrossPay(int型定期的に、 int型& timeAndHalf、 int型& doubleTime)。メイン
const int REG_RATE = 10;
const int TIME_HALF = 15;
const int DOUB_TIME = 20;
int hoursWorked = 0;
int regular = 0;
int timeAndHalf = 0;
int doubleTime = 0;
INT() {//変数
cout << "Please enter your hours worked(press -1 to quit): " << endl;
cin >> hoursWorked;
while (hoursWorked != -1);
{
if(hoursWorked >=1 && hoursWorked <=37)
{
getGrossPay(regular, timeAndHalf, doubleTime);
cout << "Your gross pay is: $ (press -1 to exit)" << regular << endl;
cout << "Please enter your hours worked(press -1 to quit): " << endl;
cin >> hoursWorked;
}
else
if (hoursWorked >=38 && hoursWorked <=50)
{
getGrossPay(regular, timeAndHalf, doubleTime);
cout << "your gross pay is: $(press -1 to exit)" << timeAndHalf << endl;
cout << "Please enter your hours worked(press -1 to quit): " << endl;
cin >> hoursWorked;
}
else
if (hoursWorked >=50)
{
getGrossPay(regular, timeAndHalf, doubleTime);
cout << "your gross pay is: $(press -1 to exit)" << doubleTime << endl;
cout << "Please enter your hours worked(press -1 to quit): " << endl;
cin >> hoursWorked;
}//end if
}//end while
} //メイン関数の最後
//****function definitions*****
void getGrossPay(int regular,
int &timeAndHalf,int &doubleTime)
{
regular = hoursWorked * REG_RATE;
timeAndHalf = hoursWorked * TIME_HALF;
doubleTime = hoursWorked * DOUB_TIME;
} // end getGrossPay function
[なぜ誰かが私を助けることができますか?実際の質問ではありませんか?](https://meta.stackoverflow.com/q/284236/62576) –
'REG_RATE'、' DOUB_TIME'、 'TIME_HALF'は' main() '関数内でのみ宣言されています。彼らは 'getGrossPay()'にアクセスできません。コードの他の不具合については、私の答えを見てください。 –