473,396 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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
3 2178
donbock
2,426 Expert 2GB
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
whodgson
542 512MB
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
whodgson
542 512MB
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

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

Similar topics

17
by: los | last post by:
Hi, I'm trying to create a program similar to that of Google's desktop that will crawl through the hard drive and index files. I have written the program and as of now I just put the thread to...
3
by: Mohammd M. Hussain | last post by:
Hi, I have a good knowledge of Perl ( 2 and half years ) and despite working with the language that long, I have yet to build a substantial program ( during this time I was merely testing out...
7
by: Peng Yu | last post by:
Hi, For example, there is a function which is called many times from different places in a program. I want measure how long this function runs in total. Of course, I can use gettimeofday to...
22
by: Qopit | last post by:
Hi there, I'm pretty new to Python and am trying to figure out how to get "will this code compile?"-like code checking. To me this is a pretty basic language/environment requirement, especially...
17
by: Franc Zabkar | last post by:
My D-Link DSL-302G modem/router has a real-time clock whose settings are volatile. To avoid hand keying the date/time via the modem's JS interface, I wonder if there is a way to copy the JS code to...
3
by: viewsonic | last post by:
Help, im a student that has to write a program for counting coins. Half of the program works but the other half doesn.t should have the following parameters. output is: Name Date total...
0
by: Frank | last post by:
Hi, I use rpy to plot functions and have the following problem. When I execute the following code line by line (start python and then execute line by line) the resulting figure looks as it...
25
by: Umesh | last post by:
i want to calculate the time required to execute a program. Also i want to calcute the time remaining for the execution of the program. how can i do that? pl mention some good websites for...
12
by: pekka | last post by:
I'm trying to measure user input time with my Timer class object. It isn't as easy as I expected. When using std::cin between timer start and stop, I get zero elapsed time. For some unknown reason,...
7
by: Bill Cunningham | last post by:
I need help on this utillity it is supposed to take as its first argument a number and its second argument a subtraction of that number say for example 20 and 2. The program should calculate the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.