434,586 Members | 992 Online + Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,586 IT Pros & Developers. It's quick & easy.

How do you get a program to figure out a percentage like time and a half

 P: 8 i know about a few errors here and have fixed them but the area of the problem is when I try to figure out the time and a half for net pay so i put in an if statement but not sure where to go from here. Expand|Select|Wrap|Line Numbers #include  #include  #include      using namespace std;   int main()     {     // Variable Declerations       int number1;     int number2;     int multiply;     int devide;     int addnumbers       // How to figure you Net and Gross pay           cout << "How much did you make this week? /n ";       // Get the first number         cout << " Enter your base pay:  ";         cin >> number1;        // Get the number of hours worked         cout << "Enter the number of hours worked: ";         cin >> number2;         {             if (number2 = 40 << devide = number1 / 2 + number1 ) ;       // Multiply number1 by number2         multiply = number1 * number2;       // Display sum         cout << " Gross pay is: " << multiply << endl;       // To figure your Net pay                   // Display sum         cout << " Your net pay is: " << devide << endl;     system ("pause");   return 0; } Sep 16 '10 #1
3 Replies

 Expert 100+ P: 2,400 Perhaps life would be easier if you used floating point instead of integers. Floating point may be a bad choice in real life, where you can't tolerate rounding errors, but it might be ok for a simple program like this. Sep 17 '10 #2

 100+ P: 542 Can you do it with a pencil and paper? There seems to be a logic problem. You get the total pay then the hours worked. Then presumably you should subtract 40 from hours worked to get time and half hours. But unless you know the base rate you can`t calculate the pay for 40 hrs or the pay for overtime Sep 17 '10 #3

 100+ P: 542 Where did the 40 come from in your program. Were you told that this was the std non-overtime hours in a week. If standard hourly rate is \$38 the OT rate will be \$57 if it is 150% of the std hourly rate Sep 18 '10 #4 