| | |
Help Required with Salary Program..
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 9
Reputation:
Solved Threads: 0
Hi,
I was coding the following program..
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
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
You'll have the same result in standard C++
- 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: C++ Syntax (Toggle Plain Text)
cin.ignore(); cin.get();
You'll have the same result in standard C++
Last edited by niek_e; Nov 13th, 2008 at 8:49 am.
![]() |
Similar Threads
- First Post Here, Question about classes and constructors. (Java)
- Java Front-end Developer Engineer for Stealth Media Start-up - Hollywood, CA (Web Development Job Offers)
- Java Front-end Developer Engineer for Stealth Media Start-up (Software Development Job Offers)
- Software Developer (Software Development Job Offers)
- I'm lost and need some help (C++)
- Please some one urgent help me in this code (C++)
- Please some one help me in this code (C++)
- New to Java, please help with first Assignment (Java)
Other Threads in the C++ Forum
- Previous Thread: Why does this work?
- Next Thread: please HELP ME!!!!
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline google graph homeworkhelper iamthwee ifstream input int integer java lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text tree unix url vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






