- Introduction from the Programmer -

This program is a simple program for the employees payment from the logistics section.We suppose that the currency is  in Euro and we dont focus on how the national tax system ison 40 Euro or in 100 Euro.Its a typical example to understand how programming is getting done with a languagelike Pascal.PROGRAM LOGISTICS(INPUT,OUTPUT);CONST  TAX=40;PAYDAY=30;OVERTIME=30;VAR SAL,WORKDAYS,OVERMONTH:INTEGER;BEGINWRITELN('HOW MANY DAYS DID YOU WORK THIS MONTH ? ');READLN(WORKDAYS);WRITELN('HOW MANY WERE YOUR OVERTIMES ?');READLN(OVERTIMES);SAL:=(PAYDAY*WORKDAYS)+(OVERTIME*OVERMONTH)-TAX;WRITELN;WRITELN;WRITE('YOUR SALARY THIS MONTH IS',SAL, ' EURO .');END. -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -Code Explanation- At the first line we type the keyword PROGRAM followed by parenthesis and the keywordsin the parenthesis INPUT separated with a comma and OUTPUT and at the end of the linethe Greek questionmark.This means that every program in Pascal is starting with the keywordPROGRAM and it will be INPUT from the keyboard and OUTPUT from the screen .Right after we declare Constants and Variables .We declare three Constants ,Tax Paydayand Overtimes (overhours) and we give the corresponding values .We declare constants with the keyword CONST(command)and variables with the keywordVAR .They both correspond in INTEGER type numbers .In the variables section we declare three variables.SAL (salary) which is the solution of theproblem we are looking for ,WORKDAYS ,(the days this employee  worked this month ,and OVERMONTH(the sum of EXTRA days that worked this month correspondingto OVERTIME which means the extra working days .After the first four lines we type the keyword BEGIN to start the body of the program whichIN IT there is the main program.Right after with WRITELN we ask how many days he worked (LN means that we leavean empty new line)and READ for giving input from the keyboard .We ask also how manywere your OVERTIMES with WRITELN and READLN .(how many extra days he worked.)After INPUT and OUTPUT Commands (WRITE,READ)we make the calculation tofind a solution (SAL) to the problem.In Pascal programming we can calculate with the upper and down comma followed bythe equal sign .So we say to find the salary (SAL)we must calculate (with math priority)and for startmultiply the daily payment(PAYDAY)with the working days(WORKDAYS)thenmultiply the overhours(OVERTIME)with the sum of extra working days(OVERMONTH)make an addition with these two multiplications and subtract the TAX which is 40 Euro.At the two last line we make the OUTPUT with WRITE and we End the body of the programwith the keyword END followed by a dot.We compile it and RUN IT.Hope for enjoy itOdysseas  


Start learning with Cybrary

Create a free account

Related Posts

All Blogs