Program Employee Salary using "IF Then Else" and "Repeat-Until" on Free Pascal Programming.

in #utopian-io8 years ago (edited)

What Will I Learn?

  • We learn how to make a program employee salary using freepascal programming.
  • how to use the command "If Then Else" and "Repeat-Until" on Free Pascal.

Example

if Data.Workingtime>200 then
Insentif:=(Data.Workingtime-200)*10000
else
Insentif:=0;
Gaber:=Group+Insentif; 

Requirements

  • Operating System; Linux, FreeBSD, Haiku, Mac OS X/iOS/iPhoneSimulator/Darwin, DOS (16 and 32 bit), Win32, Win64, WinCE, OS/2, MorphOS, Nintendo GBA, Nintendo DS, Nintendo Wii, Android, AIX and AROS.
  • Free Pascal

Difficulty

  • Basic

Tutorial Contents

Theory
Free Pascal Programming Language
A programming language is a set of coded instructions to govern computer to run certain functions. This programming language commonly used to create a software application like calculator, games, even an operating system created from the programming language. many programming languages of its kind, there are programming languages C, C++, Basic, Pascal, and others.

Free Pascal is one of the many programming languages that can serve as a compiler to generate an application. one type of instruction from Free Pascal is the "if then else", this function is used to specify more than two conditions. for example in an Office there are employees with the title and the number of hours of work are different, then the salary is paid in accordance with the working conditions of the employees.

Condition 1
If employee Group = 1 then the base salary $1000
Condition 2
If employee Group = 2 then the base salary $1500
Condition 3
If employee Group = 3 then the base salary $2000

We can input code for freepascal:

'1' : Group:='$'1000;
'2' : Group:='$'1500;
'3' : Group:='$'2000; 

Add more condition
If working hours are more than 200 hours then the employees will be the bonus with the calculation of overtime money = (working hours-200) * 1000
If working hours are less than 200 hours then the employee will not earn overtime.
The calculation of the employee's salary is base salary + overtime money

example of writing on the program

 if Data.Workingtime>200 then
Insentif:=(Data.Workingtime-200)*1000
else
Insentif:=0;
Gaber:=Group+Insentif;

Practice
The following example program employee salaries using the command "if then else" and "repeat-until".

Program employeesalary;
Program employeesalary;
Uses Wincrt;
Type staff = record
No : String[9];
Name : String[30];
payroll : Char;
Workingtime : Real;
End;
Var
Data : staff;
Group : Real;
Insentif,Gaber : Real;
Ul : Char;
Begin
Repeat
Writeln('Entry Data staff cv.raghib');
Writeln('==========================');
Writeln;
Write('No              : ');Readln(Data.No);
Write('Name        : ');Readln(Data.Name);
Write('payroll      : ');Readln(Data.payroll);
Write('Working Time : ');Readln(Data.Workingtime);
Writeln;
Writeln;
Case Data.payroll of
'1' : Group:=1000;
'2' : Group:=1500;
'3' : Group:=2000;
Else
Group:=0;
End;
if Data.Workingtime>200 then
Insentif:=(Data.Workingtime-200)*1000
else
Insentif:=0;
Gaber:=Group+Insentif;
Writeln('Report Employee Salary');
Writeln('CV. Raghib');
Writeln;
Writeln('==================================================================');
Writeln('|No            | Name           | payroll           | Workingtime                   | Gaji                   |');
Writeln('==================================================================');
Writeln('|',Data.No:10,'|',Data.Name:25,'|',Data.payroll:10,'|',Data.Workingtime:11:0,'|',Gaber:14:2,'|');
Writeln('====================================================================');
Writeln;
Write('Repeat Again? [Y/T]: ');Readln(Ul);
Until Upcase(Ul)<>'Y';
End.

1.jpg
2.jpg
3.jpg

There is also a line of code in the command "Repeat-Until" which basically, looping repeat until is similar to looping "while do" where we will do some checking in every repetition conditions are still met counter variable value or It is not.
The difference is, on the "repeat until" this condition, inspection is carried out at the end of repetition, not at the beginning like "while do."

The results of the work
Once completed in program code type, it is now time we execute in a way, we first click the compile and select compile it or press the alt + F9, after that he was on the run with the run button or ctrl + F9

4.jpg

from the photos above, it seem that all of the program code we put is correct and now we run.

5.jpg

6.jpg

Curriculum

You can also learn more code pascal by visiting the following address:

https://steemit.com/utopian-io/@raghib/program-polindrom-using-freepascal-programming



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

Your English is pretty hard to understand and your tutorial isn't that informative. It starts off well, but then towards the end you paste an entire bit of code and only explain how you executed it, not what each part of the code does.

In future tutorials please try and write in a more informative and formal manner with proper capitalisation.

You can contact us on Discord.
[utopian-moderator]

it's ok
sorry if my English is pretty hard to understand and my tutorial isn't that informative.
In future I will try to make tutorials and write in a more informative and formal manner with proper capitalisation.

semangat aduen

Coin Marketplace

STEEM 0.13
TRX 0.34
JST 0.035
BTC 108074.45
ETH 4399.12
USDT 1.00
SBD 0.83