Help Required with Salary Program..

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2008
Posts: 9
Reputation: Evil Genius is an unknown quantity at this point 
Solved Threads: 0
Evil Genius Evil Genius is offline Offline
Newbie Poster

Help Required with Salary Program..

 
0
  #1
Nov 13th, 2008
Hi,

I was coding the following program..
// Program takes work hours and rate per hour and gives total
// salary after tax, if work hours are over 40, its increased by 1.5x.

#include <iostream>
#include <conio.h>

using namespace std;

int main()
{
	double hr_work, hr_rate, taxed_total, total;

	cout <<"Enter Hours Worked (Zero to Quit): ";
	cin >> hr_work;
	cout <<"\nEnter Hourly Rate: ";
	cin >> hr_rate;

	while(hr_work>0 && hr_rate>0){

		total = hr_work*hr_rate;
		taxed_total = total - (0.18 * total);
		cout <<"\nGross Wage = "<<total;
		cout <<"\nGross Wage after Tax Deduction = "<<taxed_total;
	
   		cout <<"\n\n---------------------------------\nEnter Hours Worked (Zero to Quit): ";
		cin >> hr_work;
		cout <<"\nEnter Hourly Rate: ";
		cin >> hr_rate;
	}	 
	 			
	getch();
	return 0;
}

Now how do i make the program do the following:

If the the number Hour entered it :

45 , then the following should happen:
40 + (5 x 1.5) = 47.5
and that 47.5 should be then multiplied with hourly rate and so on..

so any help is appreciated
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 2,936
Reputation: niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute niek_e has a reputation beyond repute 
Solved Threads: 305
Moderator
Featured Poster
niek_e's Avatar
niek_e niek_e is offline Offline
Cenosillicaphobiac

Re: Help Required with Salary Program..

 
0
  #2
Nov 13th, 2008
That's not really hard if I understand your (rather vague) requirements correctly.

- take in a number
- if it's bigger then 40: subtract 40 and store the rest
- multiply the rest with 1,5 and add to 40
- multiply the outcome with hourly rate
- done

[edit]
ps. One free piece advice: Stop using the conio.h header. It's outdated and was never standard c++ to start with. I know you think you need it for getch, but if you replace getch() with:
  1. cin.ignore();
  2. cin.get();

You'll have the same result in standard C++
Last edited by niek_e; Nov 13th, 2008 at 8:49 am.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 9
Reputation: Evil Genius is an unknown quantity at this point 
Solved Threads: 0
Evil Genius Evil Genius is offline Offline
Newbie Poster

Re: Help Required with Salary Program..

 
0
  #3
Nov 13th, 2008
Thanks a lot mate!

I was so messed up with the assignments didn't really think about it.

Thanks again and for the advice too
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC