Warning

 

Close

Confirm Action

Are you sure you wish to do this?

Confirm Cancel
Member Login

Log In

A valid email is required.
Password is required.
Site Notices
3/20/2017 5:03:23 PM
Posted: 6/3/2001 6:54:47 AM EDT
I know this is off topic but I've got a program due tommorow and I'm stumped. If anyone knows C++ and would like to help me I would owe them a favor...a big favor! This is my program: Write a program using void functions. This program should calculate the amount an employee will receive in a raise based upon a certain percentage of the current salary and the amount of an employee's salary after the raise. Please use the following specifrications: This program requires 3 void functions. The first function must allow the user to put in a current salary and the percentage rate to base the raise upon. The second function must be used to calculate the raise and the new salary amount. The third function should be used to display the current salary, raise rate, raise amount, and new salary. Function prototypes should be used. The displayed values should be formatted to a precision of 2 decimal places. Show any trailing zeros. This program should contain a Do loop to allow input, calculation, and display of information for as many employees as needed. The user should be prompted with the question, "Do you wish to continue?" If the user enters in the character Y, the program should continue. Use the appropriate character function to accept either an uppercase or lowercase Y. If the user enters in another character, the program should terminate. HELP ME PLEASE!!!!!!![>(]
Link Posted: 6/3/2001 12:55:29 PM EDT
I'm not a programmer, but since none have replied, I would probably set it up something like this: /* Raise calculation */ /* includes*/ #include /* other necessary incudes here */ /*function prototypes*/ void main(void); void enterdata(double salary, double raiserate); void calculate(double salary, double raiserate, double newsalary); void display(double salary, double raiserate, double newsalary); /* now the program */ void main(void){ /* variable declarations*/ char yesno=’y’; double salary, newsalary, raiserate; /* loop through program*/ while(yesno == ‘y’){ /* call functions to do the work*/ enterdata(salary, raiserate); calculate(salary, raiserate, newsalary); display(salary, raiserate, newsalary); printf("Again? y/n"); scanf(" %1c", yesno); } /* end of while */ } /* end of main */ /* now define the functions */ void enterdata(double salary, double raiserate){ double salary, raiserate; /* input numbers to salary and raiserate */ } void calculate(double salary, double raiserate, double newsalary){ double salary, raiserate, newsalary; newsalary=salary+ (salary*raiserate/100); } void display(double salary, double raiserate, double newsalary){ double salary, raiserate, newsalary; /* display salary, raiserate, and newsalary variables */ } Hope this gives you some ideas, but it's been a while, so no warranty!
Link Posted: 6/3/2001 3:28:20 PM EDT
#include #include static void GetInput( double *pdwSalary, double *pdwRaise ); static void CalcRaise( double dwSalary, double dwRaise, double *pdwAmtOfRaise, double *pdwNewSalary ); static void PrintNewSalary( double dwSalary, double dwRaise, double dwAmtOfRaise, double dwNewSalary ); int main( int argc, char* argv[] ) { char ch; double dwSalary, dwRaise, dwAmtOfRaise, dwNewSalary; do { GetInput(&dwSalary, &dwRaise); CalcRaise(dwSalary, dwRaise, &dwAmtOfRaise, &dwNewSalary); PrintNewSalary(dwSalary, dwRaise, dwAmtOfRaise, dwNewSalary); printf("\nDo you wish to continue (y/n)? "); ch = getchar(); printf("\n"); } while (tolower(ch) == 'y'); return(0); } static void GetInput( double *pdwSalary, double *pdwRaise ) { printf("\n"); printf("Enter current salary: "); scanf("%lf", pdwSalary); fflush(stdin); printf("Enter raise as percentage: "); scanf("%lf", pdwRaise); fflush(stdin); } static void CalcRaise( double dwSalary, double dwRaise, double *pdwAmtOfRaise, double *pdwNewSalary ) { *pdwAmtOfRaise = dwSalary * (dwRaise / 100.0); *pdwNewSalary = dwSalary + *pdwAmtOfRaise; } static void PrintNewSalary( double dwSalary, double dwRaise, double dwAmtOfRaise, double dwNewSalary ) { printf("\n"); printf("Old Salary: %10.02lf\n", dwSalary); printf("Raise: %10.02lf%%\n", dwRaise); printf("Amt of Raise: %10.02lf\n", dwAmtOfRaise); printf("New Salary %10.02lf\n", dwNewSalary); }
Link Posted: 6/3/2001 4:14:28 PM EDT
Thanks guys!! I have already hacked out the majority of code. Where I was hung up was the passing of variables from one fuction to the other. mattja your code turned the lightbulb on for me!! Again thank you very much! If I can ever help you out I'll try! [/i]Keep Your Powder Dry!![/i]
Link Posted: 6/3/2001 6:17:31 PM EDT
No problem mtnpatriot. You didn't specify if you wanted classes, which is the whole point of the C++ language, so I wrote it in standard "C" fashion. If you every need any pointers (no pun intended), send me an e-mail.
Link Posted: 6/3/2001 6:37:46 PM EDT
[Last Edit: 6/3/2001 6:36:02 PM EDT by MG_ME]
MadMatt: Iam not a programmer! Yea you are if you can write easy fuction's like this. You could come up with a class. #include class Emp_Sal { public: void enterdata(salury, raiserate); void calculate(salury, raiserate, newsalury); void display(salury, raiserate, newsalury); private: double salury, raiserate, newsalury; }; main() { ETC! ECT! ECT! } main basically the same of what these guy's wrote but more managable. i use Visual C++ 6.0 which really helps with managing your classes with popup windows.
Link Posted: 6/3/2001 6:48:54 PM EDT
Death to C++!!! Long live K&R C!!!!!!
Top Top