|
Our first problem was, given a specific pay rate of 16.78, write a program which calculates gross pay minus all the federal taxes, state taxes, social security taxes, union dues (which was a constant) and health care (which was a constant given you take care of more than 3 dependents), and then give the net pay.
Here's how I did it.
#include
do
if (hours > reg_hours)
sst = gross_pay*.06;
net_pay = gross_pay - (sst + fit + sit + UNION + health);
cout.setf(ios::fixed);
cout << "Good-Bye\n";
return 0;
--------------------------------------------
Now I know what you're thinking, wow that was crazy! Well, that problem actually gave me less trouble than this current one I'm about to give. It's all because I was trying to make the problem waaaaaaay too complicated when it was really more simple than I was making it out to be.
This second problem, we had to write a program that reads in 10 whole numbers and then gives the sum of all the positive numbers, then gives the sum of all the negative numbers, and finally gives the sum of all the numbers together.
At first I went about this problem by trying to give each separate value a name, but that's what took me down the road of trouble. I didn't know I could just have one name for each value regardless of how many I put in! That made things soo much more easier. I also tried to make the program check for positive and negative numbers as well as stick whatever number into an "all" category, but that didn't work out so well either. Thanks partly go out to my brother who said that the sum of all numbers would be the sum of all positives + the sum of all negatives, instead of having a whole separate name for the sum of all. The other thanks go out to the few internet pages I came across which gave me hints on how to go about completing this problem.
Here's how I did this problem eventually.
#include
sum_p = 0;
cout << "You will be entering 10 whole numbers.\n";
while (count <= 10)
cout << "The sum of all positive numbers is:\n";
return 0; |