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:-/

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:

cin.ignore();
cin.get();

You'll have the same result in standard C++ :)

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 :)

This question has already been answered. Start a new discussion instead.