I was curious to know why when I enter a number of hours more than 169 does my program just doesn't end and give the statement?
Code:
#include <iostream>
float hours; // how many hours the employee worked for that week
float wages; // the employees hourly wage
float paycheck; //employees weekly pay
float overtime; //time and half
int impossible; // impossible number of hours to work in a week
int main()
{
impossible = 168;
std::cout << "Enter how many hours you worked: ";
std::cin >> hours;
std::cout << "Enter your hourly wage here: ";
std::cin >> wages;
if (hours > impossible)
{
std::cout << "It is impossible to work that long in seven days.\n";
paycheck == 0;
}
else if (hours < 40)
{
paycheck = hours * wages;
std::cout << "You have earned $"<< paycheck << " for this week.\n";
}
else (hours > 40);
{
overtime = (hours - 40) / 2;
paycheck = (hours + overtime) * wages;
std::cout << "You have earned $"<< paycheck << " for this week.\n";
}
return (0);
}
Code:
Enter how many hours you worked: 190
Enter your hourly wage here: 8
It is impossible to work that long in seven days.
You have earned $2120 for this week.
Bookmarks