Convert the following arithmetic expression from infix to reverse polish notation a. G*F1+1-J+K*L [4] b. A*13+A*(BeD+CT) Convert the following arithmetic expression from reverse polish notation to...

Convert the following arithmetic expression from infix to reverse polish notation a. G*F1+1-J+K*L [4] b. A*13+A*(BeD+CT) Convert the following arithmetic expression from reverse polish notation to infix notation. a. ABCDE+*-/ b. ABCDEFG+•+•+• Write the program to evaluate— + ()a. Using a general register computer with three address instruction [5] b. Using a general register with a two address instruction [5] c. Using a general register with a one address instruction [5] d. Using a general register with zero address instruction


Question 1 Question 2 Question 3 Question 4 Question 5 (Reference assignment 2c attached as a separate pdf to answer question 5) Question 6 This is the solution to assignment 1a – questions after this solution is based on this – please reference this to answer questions after C++ Code for this is; Output ANSWER THESE QUESTIONS BELOW FOR THE CODE ABOVE WHICH IS ASSIGNMENT 1A ANSWER 2C ANSWER DELETE.pdf 2C 1 #include 2C 2 #include "functions.h" int main() { FILE *fp = fopen("Report.txt", "w"); if (fp == NULL) { puts("Couldn't open file"); return 0; } PrintReportHeadings(fp); int empCount=0; float totreg,totovt, totpayrate, totgross, totfed, totstate, totssi, todefr, totnetpay; InitializeAccumulators(&totreg,&totovt, &totpayrate, &totgross, &totfed, &totstate, &totssi, &todefr, &totnetpay); char ch; do{ char firstname[20],lastname[20]; float payRate, hours, defr; InputEmployeeData(lastname,firstname, &hours, &payRate, &defr); float gross=0.0; gross=CalculateGross(hours,payRate); float fedtax=0.0,statetax=0.0, ssitax=0.0; CalculateTaxes (gross, defr, &fedtax, &statetax, &ssitax); float netpay=gross-fedtax-statetax-ssitax-defr; float reghrs=0.0,ovthrs=0.0; if(hours<=40) reghrs="hours;" else="" {="" reghrs="40;" ovthrs="hours-40;" }="" char="" *name="lastname;" strcat(name,",="" ");="" strcat="" (name,firstname);="" fprintf(fp,="" "\n\n%-15s%5s%7.2f%5s%7.2f%5s%7.2f%5s%7.2f%5s%7.2f%5s%7.2f",="" name,"",payrate,"",reghrs,"",gross,"",fedtax,"",ssitax,"",netpay);="" fprintf(fp,="" "\n%-15s%5s%7s%5s%7.2f%5s%7s%5s%7.2f%5s%7.2f%5s%7s",="" "","","","",ovthrs,"","","",statetax,"",defr,"","");="" adddetailtoaccumulators(reghrs,="" &totreg,="" ovthrs,="" &totovt,="" payrate,="" &totpayrate,="" gross,="" &totgross,="" fedtax,="" &totfed,="" statetax,="" &totstate,="" ssitax,="" &totssi,="" defr,="" &todefr,="" netpay,="" &totnetpay);="" empcount="empCount+1;" 2c="" 3="" printf("do="" yo="" like="" to="" add="" more="" employees(y/n)");="" scanf("="" %c",&ch);="" }while(ch="='y');" printsummaryreport(totreg,totovt,="" totpayrate,="" totgross,="" totfed,="" totstate,="" totssi,="" todefr,="" totnetpay,="" empcount,="" fp);="" fclose(fp);="" }="" #ifndef="" functions_h="" #define="" functions_h="" #include=""> void PrintReportHeadings(FILE * reportfile); void InitializeAccumulators(float *totreg,float *totovt, float *totpayrate, float *totgross, float *totfed, float *totstate, float *totssi, float *todefr, float *totnetpay); void InputEmployeeData(char *lastname, char *firstname, float *hours, float *payrate, float *defr); float CalculateGross(float hours, float payrate); float CalcFedtax(float gross, float deferred); float CalcStatetax(float fedtax); float CalcSSItax(float gross, float deferred); void CalculateTaxes (float gross, float deferred, float *fedtax, float *statetax, float *ssitax); void AddDetailToAccumulators(float reghrs, float *totreg, float ovthrs, float *totovt, float payrate, float *totpayrate,float gross, float *totgross, float fedtax, float *totfed, float statetax, float *totstate, float ssitax, float *totssi, float defr, float *todefr, float netpay, float *totnetpay); void PrintSummaryReport(float totreg,float totovt, float totpayrate, float totgross, float totfed, float totstate, float totssi, float todefr, float totnetpay, int numemmps, FILE *reportfile); #endif // FUNCTIONS_H #include "functions.h" void PrintReportHeadings(FILE * reportfile) 2C 4 { fprintf(reportfile, "%-15s%5s%-7s%5s%-7s%5s%-7s%5s%-7s%5s%-7s%5s%-7s", "Employee","","Pay","","Reg Hrs","","Gross","","Fed","","SSI","","Net"); fprintf(reportfile, "\n%-15s%5s%-7s%5s%-7s%5s%-7s%5s%-7s%5s%-7s%5s%-7s", "Name","","Rate","","Ovt Hrs","","Pay","","State","","Defr","","Pay"); fprintf(reportfile, "\n%-15s%5s%-7s%5s%-7s%5s%-7s%5s%-7s%5s%-7s%5s%-7s", "========","","=====","","=======","","=======","","=======","","=======","","==== ==="); } void InitializeAccumulators(float *totreg,float *totovt, float *totpayrate, float *totgross, float *totfed, float *totstate, float *totssi, float *todefr, float *totnetpay) { *totreg=0.0; *totovt=0.0; *totpayrate=0.0; *totgross=0.0; *totfed=0.0; *totstate=0.0; *totssi=0.0; *todefr=0.0; *totnetpay=0.0; } void InputEmployeeData(char *lastname, char *firstname, float *hours, float *payrate, float *defr) { printf("First Name: "); scanf("%s",firstname); printf("Last Name: "); scanf("%s",lastname); printf("Hourly pay rate: "); scanf("%f",payrate); printf("Total hours worked for this pay period: "); scanf("%f",hours); printf("Amount of Deferred Earnings: "); scanf("%f",defr); } float CalculateGross(float hours, float payrate) { float gross=0.0; if(hours<=40) gross=hours*payrate; else gross=(payrate*40)+((hours-40)*1.5*payrate); return gross; } 2c 5 float calcfedtax(float gross, float deferred) { return 0.15*(gross-deferred); } float calcstatetax(float fedtax) { return 0.07* fedtax; } float calcssitax(float gross, float deferred) { return 0.0775*(gross-deferred); } void calculatetaxes (float gross, float deferred, float *fedtax, float *statetax, float *ssitax) { *fedtax=calcfedtax(gross,deferred); *statetax=calcstatetax(*fedtax); *ssitax=calcssitax(gross,deferred); } void adddetailtoaccumulators(float reghrs, float *totreg, float ovthrs, float *totovt, float payrate, float *totpayrate,float gross, float *totgross, float fedtax, float *totfed, float statetax, float *totstate, float ssitax, float *totssi, float defr, float *todefr, float netpay, float *totnetpay) { *totreg=*totreg+reghrs; *totovt=*totovt+ovthrs; *totpayrate=*totpayrate+payrate; *totgross=*totgross+gross; *totfed=*totfed+fedtax; *totstate=*totstate+statetax; *totssi=*totssi+ssitax; *todefr=*todefr+defr; *totnetpay=*totnetpay+netpay; } void printsummaryreport(float totreg,float totovt, float totpayrate, float totgross, float totfed, gross="hours*payrate;" else="" gross="(payrate*40)+((hours-40)*1.5*payrate);" return="" gross;="" }="" 2c="" 5="" float="" calcfedtax(float="" gross,="" float="" deferred)="" {="" return="" 0.15*(gross-deferred);="" }="" float="" calcstatetax(float="" fedtax)="" {="" return="" 0.07*="" fedtax;="" }="" float="" calcssitax(float="" gross,="" float="" deferred)="" {="" return="" 0.0775*(gross-deferred);="" }="" void="" calculatetaxes="" (float="" gross,="" float="" deferred,="" float="" *fedtax,="" float="" *statetax,="" float="" *ssitax)="" {="" *fedtax="CalcFedtax(gross,deferred);" *statetax="CalcStatetax(*fedtax);" *ssitax="CalcSSItax(gross,deferred);" }="" void="" adddetailtoaccumulators(float="" reghrs,="" float="" *totreg,="" float="" ovthrs,="" float="" *totovt,="" float="" payrate,="" float="" *totpayrate,float="" gross,="" float="" *totgross,="" float="" fedtax,="" float="" *totfed,="" float="" statetax,="" float="" *totstate,="" float="" ssitax,="" float="" *totssi,="" float="" defr,="" float="" *todefr,="" float="" netpay,="" float="" *totnetpay)="" {="" *totreg="*totreg+reghrs;" *totovt="*totovt+ovthrs;" *totpayrate="*totpayrate+payrate;" *totgross="*totgross+gross;" *totfed="*totfed+fedtax;" *totstate="*totstate+statetax;" *totssi="*totssi+ssitax;" *todefr="*todefr+defr;" *totnetpay="*totnetpay+netpay;" }="" void="" printsummaryreport(float="" totreg,float="" totovt,="" float="" totpayrate,="" float="" totgross,="" float="">
Nov 26, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here