until the returned result is 0. It's for a school assignment. This is my first time trying to implement a loop, so I just need to understand how to correctly write out the loop and what condition I should use.
// GrossPay.cpp : Defines the entry point for the console application.
#include <iostream>
usingnamespace std;
int main()
{
double hourly_rate;
double hours;
double gross_pay = 1;//initialize variable
while (gross_pay >= 1) {
printf("Please input the hourly rate of the employee: ");
cin >> hourly_rate;
printf("Please input the number of hours worked by the employee: ");
cin >> hours;
if (hours <= 40)
{
gross_pay = hours * hourly_rate;
}
else
{
gross_pay = (40 * hourly_rate) + (hours - 40) * (hourly_rate * 1.5);
}
cout << "The gross pay of this employee is $" << gross_pay << "." << endl;
}
return 0;//return goes out side loop
}
Nice! Ok, so I input the changes you have made, and the program runs! You are amazing! Thanks for the help that you provided. Now I can work on learning these loops more thoroughly.