By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,586 Members | 992 Online
Bytes IT Community
+ 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
  1. #include <iostream>
  2. #include <string>
  3. #include <cmath>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9.  
  10.  
  11. {
  12.     // Variable Declerations
  13.  
  14.     int number1;
  15.     int number2;
  16.     int multiply;
  17.     int devide;
  18.     int addnumbers
  19.  
  20.     // How to figure you Net and Gross pay
  21.  
  22.         cout << "How much did you make this week? /n ";
  23.  
  24.     // Get the first number
  25.         cout << " Enter your base pay:  ";
  26.         cin >> number1; 
  27.  
  28.     // Get the number of hours worked
  29.         cout << "Enter the number of hours worked: ";
  30.         cin >> number2;
  31.         {
  32.             if (number2 = 40 << devide = number1 / 2 + number1 ) ;
  33.  
  34.     // Multiply number1 by number2
  35.         multiply = number1 * number2;
  36.  
  37.     // Display sum
  38.         cout << " Gross pay is: " << multiply << endl;
  39.  
  40.     // To figure your Net pay
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.     // Display sum
  49.         cout << " Your net pay is: " << devide << endl;
  50.  
  51.  
  52. system ("pause");
  53.  
  54. return 0;
  55. }
Sep 16 '10 #1
Share this Question
Share on Google+
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

Post your reply

Sign in to post your reply or Sign up for a free account.