オンラインの C++ クラスを受講していますが、学習に苦労しています。以下の問題のコードで何が間違っているのか正確にはわかりません。時間数 = 40 の場合は式が正しくなりますが、時間数が 40 を超えるか 40 未満の場合は何か問題が発生しています。ご協力ありがとうございます。乾杯、R.
Problem:
if hrs <= 40 the regular pay = hrs times pay rate
if hrs > 40 then overtime pay = 1.5 times (hrs - 40) times pay rate
gross pay = regular pay plus overtime pay
// my code
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
//variable declarations
int EmployeeIdentificationNumber = 0;
double Hours = 0;
double PayRate = 0;
double GrossPay = 0;
double RegularPay = 0;
double OvertimePay = 0;
std::cout << "Welcome to the Employee Payroll.\n"; // display message
std:: cout << "Enter Your Employee Identification Number: "; //promp user for data
std::cin >> EmployeeIdentificationNumber; //read integer from user into EmployeeIdentificationNumber
std::cout << "Please enter Hours worked: " ; // prompt user for data
std::cin >> Hours; //read integer from user into Hours
std::cout << "Please enter Pay Rate: " ; // prompt user for data
std::cin >> PayRate; //read integer from user into PayRate
RegularPay = Hours * PayRate; //calculate RegularPay
OvertimePay = 1.5 * (Hours - 40) * PayRate; //Calculate Overtime
//Qualifier for RegularPay
if (Hours <= 40);
RegularPay = Hours * PayRate;
OvertimePay = 0;
GrossPay = RegularPay + OvertimePay;
std::cout << "Gross Pay is = $" ;
//Qualifier for OverTime
if (Hours > 40);
RegularPay = Hours * PayRate;
OvertimePay = 1.5 * (Hours - 40) * PayRate;
GrossPay = RegularPay + OvertimePay;
std::cout << RegularPay + OvertimePay << std::endl;
std::cout << "Thanks for using the Employee Payroll\n";
system("PAUSE");
return EXIT_SUCCESS;
}