Case study
A company will calculate the total employee salary with the following provisions:
Allowances:
- Marriage = 75,000,-
- Not married = 20,000,-
Bonus:
- Gol. i = 150,000,-
- Gol. ii = 175,000,-
- Gol. iii = 200,000,-
Basic salary:
- Gol. i = 2,000,000,-
- Gol. ii = 2,750,000,-
- Gol. iii = 3,500,000,-
Total salary = basic salary + bonus + allowances
Completion
C++ Determining Entry Level Employee Salary
Source code:
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
/**
*bundet.com
*Menghitung Total Gaji Tingkat Pemula
*/
void main()
{
char nama[20], tunjangan_nikah[2], gol[6];
int total_gaji, total, nkh;
long y, n, bi, bii, biii, gpi, gpii, gpiii;
y = 75000;
n = 20000;
bi = 150000;
bii = 175000;
biii = 200000;
gpi = 2000000;
gpii = 2750000;
gpiii = 3500000;
repeat:
cout << "nama : "; gets (nama);
cout <<endl;
cout << "nikah (y/n) : "; cin >> tunjangan_nikah;
cout <<endl;
cout << "gol (i/ii/iii) : "; cin >> gol;
cout <<endl;
if (strcmp(tunjangan_nikah,"y")==0){nkh = y;}
else if (strcmp(tunjangan_nikah,"n")==0){nkh = n;}
else {cout <<"\n >>>Kode Yang Anda Masukan Salah<<<!!!"<< endl <<endl;
goto repeat;}
if(strcmp(gol,"i")==0){total = bi + gpi;}
else if(strcmp(gol,"ii")==0){total = bii + gpii;}
else if(strcmp(gol,"iii")==0){total = biii + gpiii;}
else{cout <<"\n >>>Kode Yang Anda Masukan Salah<<<!!!"<< endl <<endl;
goto repeat;}
total_gaji = nkh + total;
cout << "total gaji :Rp"<< total_gaji;
getch();
}
Hello Young Scholars, if you know, many statements about structured programming say that a good program is a program that is far from the goto: command, but a question arises from us, why if a goto: instruction is so much avoided by a programmer? if so, then why was the goto: instruction created?
It is very ironic, so we have our own opinion, that the goto: instruction is not always to be avoided, but its use is more conditional or incidental, meaning; it does not mean that the goto: instruction should not be used, but rather do not let goto: dominate the structure of the program you create, it is good if there is only a maximum of 1, and if there is none, that is even better.
C++ Employee Pay Slip
Source Code:
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <iomanip.h>
/**-----------------------------------------------------------------------------
*bundet.com
*Penggajian
------------------------------------------------------------------------------*/
void main(){
char nama[99],pddkn[10],sn,yes;
int tsn,gol,lk,th,hr;
long thr,jml;
float tpddkn,tlk,tt,tgol;
const gj_pkk=950000;
atas:
cout<<" Program Hitung Gaji Karyawan"<<endl<<endl;
cout<<" PT. Code Correct"<<endl;
cout<<"----------------------------------"<<endl<<endl;
cout<<"Nama Karyawan : "<<setw(5);gets(nama);
cout<<"Status Nikah (Y/T) : "<<setw(5);cin>>sn;
cout<<"Golongan (1/2/3) : "<<setw(5);cin>>gol;
cout<<"Pendidikan (D3/S1/S2/S3) : "<<setw(5);cin>>pddkn;
cout<<"Lama Kerja : "<<setw(5);cin>>lk;
cout<<"Jumlah Hari Masuk kerja : "<<setw(5);cin>>hr;
//--------------------------------klrga--------------------------------------
if(sn=='y'|| sn=='Y'){
tsn=150000;
}
else if(sn=='t'|| sn=='T'){
tsn=0;
}
else{
clrscr();
cout<<" Maaf Kode Status Nikah Anda Salah!!!"<<endl<<endl;
goto bawah;
}
//--------------------------------jabatan------------------------------------
if(gol==1){
tgol=0.05*gj_pkk;
tt=10000*hr;
}
else if(gol==2){
tgol=0.1*gj_pkk;
tt=20000*hr;
}
else if(gol==3){
tgol=0.15*gj_pkk;
tt=25000*hr;
}
else{
clrscr();
cout<<" Maaf Kode Jabatan Anda Salah!!!"<<endl<<endl;
goto bawah;
}
//--------------------------------pddkn----------------------------------------
if(strcmp(pddkn,"d3")==0||strcmp(pddkn,"D3")==0){
tpddkn=0.05*gj_pkk;
}
else if(strcmp(pddkn,"s1")==0||strcmp(pddkn,"S1")==0){
tpddkn=0.075*gj_pkk;
}
else if(strcmp(pddkn,"s2")==0||strcmp(pddkn,"S2")==0){
tpddkn=0.1*gj_pkk;
}
else if(strcmp(pddkn,"s3")==0||strcmp(pddkn,"S3")==0){
tpddkn=0.125*gj_pkk;
}
else{
clrscr();
cout<<" Maaf Kode Pendidikan Anda Salah!!!"<<endl<<endl;
goto bawah;
}
//----------------------------------bonus------------------------------------
if(lk==0){
tlk=0;
}
else if(lk==1){
tlk=0.025*gj_pkk;
}
else if(lk==2){
tlk=0.05*gj_pkk;
}
else if(lk==3){
tlk=0.075*gj_pkk;
}
else if(lk>=4){
tlk=0.1*gj_pkk;
}
else {
clrscr();
cout<<" Maaf Kode Lama Kerja Anda Salah!!!"<<endl<<endl;
goto bawah;
}
//-------------------------------jmlhr----------------------------------------
if(hr>20){
thr = hr / 20 * gj_pkk + gj_pkk;
}
else if(hr<=20){
thr= gj_pkk;
}
else {
clrscr();
cout<<" Maaf Kode Lama Kerja Anda Salah!!!"<<endl<<endl;
goto bawah;
}
jml= thr+tgol+tpddkn+tt+tsn+tlk;
//------------------------------------------------------------------------------
cout<<endl<<endl;
cout<<"Karyawan yang bernama : "<<setw(5)<<nama<<endl<<endl;
cout<<"Gaji Yang Diterima"<<endl<<endl;
cout<<"Gaji Pokok + Lembur :Rp."<<setw(5)<<thr<<endl;
cout<<"Tunjangan Jabatan :Rp."<<setw(5)<<tgol<<endl;
cout<<"Tunjangan Pendidikan :Rp."<<setw(5)<<tpddkn<<endl;
cout<<"Tunjangan Transportasi :Rp."<<setw(5)<<tt<<endl;
cout<<"Tunjangan Keluarga :Rp."<<setw(5)<<tsn<<endl;
cout<<"Bonus :Rp."<<setw(5)<<tlk<<endl;
cout<<"-------------------------------------------- +"<<endl<<endl;
cout<<"Gaji Yang Diterima :Rp."<<setw(5)<<jml<<endl<<endl;
bawah:
cout<<"Entry Data lagi (Y/T) ?";cin>>yes;
if(yes=='Y'||yes=='y'){
clrscr();
goto atas;
}
else if(yes=='N'||yes=='n'){
clrscr();
cout<<"\n THANK YOU";
}
else{
clrscr();
cout<<"\n THANK YOU";
}
getch();
}
If you have any questions, don't hesitate to ask them in the comments column. Thank you. Hopefully this is useful and happy learning.
Some questions that have been asked by visitors:
GILDA FEBRIANDINI Apr 10, 2016, 06:22:00 = Assalamualaikum, I want to ask about a program to determine the number of odd and even numbers based on the amount of data N entered, but must use for one only, thank you for the answer.
DIAN ASMAUL HUSNA Apr 12, 2016, 11:54:00 = Assalamualaikum I want to ask about each employee is charged 1% of gross salary received and each employee is taxed based on gross salary? Thank you for your answer
SISKA RAHMA May 9, 2016, 20:37:00 = is it possible for minGW?
HALIM BARCA May 11 2016, 14:25:00 = how do you understand programming, bro, I'm confused, bro, I'm majoring in informatics engineering but my programming is 0 embarrassed, please advise, bro.
ADIL TAMBUNAN 17 Jul 2017, 02:32:00 = what does flowchart mean bro,
SISKA RAHMA May 14, 2016, 14:26:00 = MinGW (Minimalist GNU for Windows), formerly MingW32, is a free and open source development environment for native Microsoft Windows applications. It includes a port of the GNU Compiler Collection (GCC), the GNU Binutils for Windows (assembler, linker, archive manager), a freely distributed set of Windows-specific header files and static import libraries that allow use of the Windows API, a native Windows build of the GNU debugger, and other utilities. MinGW does not rely on third-party C runtime DLL files, and since the runtime libraries are not distributed using the GNU General Public License (GPL), there is no need to distribute source code with the resulting program, unless the GPL libraries are used elsewhere in the program. MinGW can be run either on the native MS-Windows platform or cross-hosted on GNU/Linux
ARFIANDI W 31 Aug 2016, 18:07:00 = bro, I can't RUN, "Function "strcmp" should have a prototype" error
RAMA A DEWANTARA Oct 15, 2016, 12:35:00 = Bro, what software do you use for this? Using Turbo C++ 3.2 gives an error, it says function strcmp should have a prototype
ANONYMOUS 16 Oct 2016, 17:39:00 = If I may ask, what version is it, bro?
RAMA A DEWANTARA Oct 16, 2016, 21:54:00 Sorry, bro, I want to ask again, right there, bro, for if if the input is a number, the code is if(lk==0){ tlk=0; } if using letters, how should I do it, bro? because I'm working on an assignment from a lecturer, the input for the group uses letters, bro
UNKNOWN 25 Oct 2016, 20:59:00 = Bro, is the work time calculated in years, days or hours? Please enlighten me.
HARDI YANTO Oct 26, 2016, 09:41:00 = I got this task, bro. Maybe you can help me. For employees who have worked for at least 5 years and have a maximum salary of 3.5 million, they get compensation of 20% of their basic salary, other than that they only get 10%. How about the coding and algorithm, bro?
HERMAN SANJAYA 26 Oct 2016, 12:02:00 = How do you make the maximum number of days to come in 31, bro...?
HARDI YANTO Oct 26, 2016, 12:21:00 = one more question, hopefully you still want to help, is the calculation in hrs, right? Please explain and where does the 10 percent go? Sorry for asking a lot because I'm still a newbie
HERMAN SANJAYA Oct 26, 2016, 11:52:00 = Wow.. Awesome Bro....!!! There's a lot of knowledge, let me edit a little bit, bro..
HARDI YANTO Oct 26, 2016, 14:58:00 = So for the case above, I only have to modify the bonus section, right? Okay, bro, it works, thanks for the input, it's very helpful. Oh yeah, the last one. How do we know the year calculation?
SHOFIYA CHILMI Oct 29, 2016, 16:06:00 = sorry for disturbing your time, it uses C++, if it uses C, can it be done, min? because I don't use C++ so I'm confused, thanks, min
IRWAN PANJAITAN Nov 14, 2016, 14:52:00 = Bro, I've created the algorithm like the one above, but what about the output?
UNKNOWN 5 Dec 2016, 07:42:00 = Bro, please help me with the coding above but using the function
SAHARIA JAMIL 19 Dec 2016, 12:43:00 = hello.. I run it but I get an error in the Const = 9500000 section.. what's that?
ROSIDA HANDANI 25 Mar 2017, 20:28:00 = bro, can you post a tax calculation program? It's sad that when it's run it doesn't match expectations. Please help, bro, it's a campus assignment.
UNKNOWN Jul 6, 2017, 12:24:00 = MY BOSS IS A LAYMAN, CAN YOU MAKE A PROGRAM FOR SALARY INPUT. THIS IS MY WA 081249084999
SYAHAB SOLEHUDIN Jul 13, 2017, 09:42:00 = Baruis ke 13 after d run why is it wrong? please enlighten me
SEPTIAN FM 13 Oct 2017, 01:57:00 Please help....I'm really having a hard time..\
1) The salary received by employees consists of basic salary, allowances and overtime pay.\
a. The basic salary is determined based on the position and employee concerned
- operator Rp. 2,000,000
- manager Rp. 3,500,000
b. allowances are determined based on the marital status of the employee concerned
- If the employee is not married, the allowance he gets is 5% of the gapok
- If an employee is married, the allowance received is 10% of the salary
- If an employee is married and has children, the allowance received is 15% of the salary
c. overtime pay is determined based on
- the amount of overtime pay is 2.5% of the gapok
- an employee may not work overtime more than 20 hours per month.
2) input input
- a. employee number
- b. employee name.
- c. position
- d. number of overtime hours
- e. marital status
- f. number of children
3) output output
- a. name
- b. position
- c. marital status (single, married, have children or not)
- d. basic salary
- e. allowance
- f. number of overtime hours
- g. the amount of overtime pay received
- h. total employee salary
Please help me by Friday, collect it with the flowchart....thank you
NGAPAKERS 22 Oct 2017, 21:09:00 = Nice blog, bro, I like the content of the blog
RINI PUTRI 10 Dec 2017, 18:06:00 Assalammualikum sis, I want to ask how to make this C++ program sis: 1) Using the switch-case or gotu concept (choose the one you can) make a program that displays a menu consisting of:
- Biodata,
- Employee Salary Calculation Program,
- Exit/exit.
2) For menu 1. Biodata, contains your biodata consisting of name, student ID number, date of birth, local, department, and faculty.\
3) For menu 2. Employee Salary Calculation Program which has the following provisions:\
a. Basic salary per month is Rp. 1,800,000;\
b. Position allowance
- Group 1: 5% * Basic salary
- Group 2: 10% * Basic salary
- Group 3 :15% * Basic salary
4) Overtime honorarium Rp. 15,000;/hour. Where the required amount of work is 8 hours for 5 days within 1 month (4 weeks) so that the mandatory work hours total 160 hours. Excess working hours are counted as overtime hours. So the total overtime honorarium = overtime hours * Rp. 15,000;\
5) Total honorarium received = Basic Salary + Position Allowance + Total Overtime Honorarium.\
6) The input screen consists of:
- Your PT.NIM Employee Salary Calculation Program
- Employee Name :
- Job Class (1/2/3) :
- Number of Working Hours:
7) The output screen is:
- Named Employee
- The honorarium received consists of:
- Position Allowance Rp..................
- Overtime honorarium Rp...........
- Basic Salary Rp................
- Total Salary Rp..................
8) For menu 3. Exit, if selected, the program stops or exits the program
UNKNOWN Jan 12, 2018, 08:38:00 How do we do it if we use more than one procedure?
What a question!
Create an Algorithm, Flowchart, and Program to Calculate Employee's Net Salary with the following conditions: Basic Salary: 2,000,000 Position Allowance for Head: 1,000,000 Section Head: 500,000 Staff: 250,000 Gross Salary = Basic Salary + Position Allowance Family Allowance: Married: Wife or Husband: 10% of Gross Salary Children: 5% of Gross Salary (Max 2 children) Income Tax: 5% of Gross Salary Net Salary = Gross Salary + Family Allowance - Tax.
Here is our response at that time:
Hello Gilda Febriandini, the program is in this link C++ Finding / Determining Even, Odd or Zero Integers , Happy learning, and good luck
Hello DIAN ASMAUL HUSNA, to add 1% tax for each employee, please just create a new variable that explains the tax, for example I created a long pjk variable = gjpokok * 1/100 after that in the calculation of net salary or Total Salary, please add the pjk variable to reduce, for example: long totgaji = A+B+C-pjk that's it, Miss Dian, I hope you agree, thank you
Hello SISKA RAHMA, sorry, what is minGW? please explain first, thank you
Hello Halim Barca, my suggestion:
- Don't jump straight into coding,
- Create a picture in your mind of how a program will work.
- Express into flowchart
- Don't rush into coding until you feel truly proficient in using flowcharts.
- Do not give up
- Pray
Like the design of a program workflow diagram (so the program's progress is depicted graphically) Like the following example -> HOW TO PRESENT ALGORITHMS
Ooo the original Windows compiler, I've tried it and it turns out it doesn't work, there are several libraries that need to be changed such as < iosteram > without .h and while other libraries don't need changes... but after compiling there are many error instructions.
GCC VERSION:
COMPILATION RESULTS:
I just ran it, bro, and it's still running smoothly. If I may, what compiler do you use? I ran the above using Borland C++, what do you use bro?
I'm using Borland C++, bro, please adjust it
Borland C++ Version 5.02 Copyright 1991, 1997 Borland International, Inc. All Rights Reserved.
The example above is quite complete, there is if using numbers, then the variable is of type "integer", there is if using letters, then the variable is of type "char", as in the following example:
if(sn=='y'|| sn=='Y'){
tsn=150000;
}
If you want to use if with letter parameters, then you need to make the variable of type "char"
Length of service = how many years, because it determines the value of the allowance. Number of days of service = how many days, because it determines the value of the basic salary.
Hi Hardi Yanto, the algorithm and program framework are not much different from this:
if(hr>20){
thr = hr / 20 * gj_pkk + gj_pkk;
}
else if(hr<=20){
thr= gj_pkk;
}
else {
clrscr();
cout<<" Maaf Kode Lama Kerja Anda Salah!!!"<
You only need to modify the variables, parameters and statements in the branching block. If you do not understand how to modify it, please understand the basic concept first by searching for material entitled: "UNDERSTANDING BRANCHING IN C++" "Example of C++ Program REPETITION and BRANCHING" Please use the search box above to do a quick search. Happy learning and Good Luck!
@Hardi Yanto,
- hr = variable for input of working days (days)
- lk = variable for input of length of service (years)
10% is in the bonus branching block, specifically for 4 years and above. You can modify this section:
//----------------------------------bonus------------------------------------
if(lk==0){
tlk=0;
}
else if(lk==1){
tlk=0.025*gj_pkk;
}
else if(lk==2){
tlk=0.05*gj_pkk;
}
else if(lk==3){
tlk=0.075*gj_pkk;
}
else if(lk>=4){
tlk=0.1*gj_pkk;
}
else {
clrscr();
cout<<" Maaf Kode Lama Kerja Anda Salah!!!"<
Hii Herman Sanjaya, welcome. Answering your question above, about how to limit work to a maximum of 31 work is enough by determining the branching condition/parameter to if(hr<=31) meaning the day input is only valid from 31 - down. Then to avoid errors, please make an exception, for example:
else{
cout<<"Maaf Anda berlebihan, setiap bulan tidak lebih dari 31 hari!!! wkwkwkwkw"<
For the case you asked = yes / correct, but if you modify the variable name too, then don't forget to declare it above, after void main(){
The year is not counted, bro, it is just entered randomly, for example: For example, you have 4 employees (A, B, C, D) A has worked in your company for 5 years (the oldest), B has only been there for 3 years (quite old), C has only been there for 1.7 years (senior), D has only been there for 0.8 years (let's just say 8 months, still a newbie). So that's it, bro, well it's called a program for learning, the important thing is to understand the workflow. That's it, bro, that's it for now, this is the last one, thank you and happy learning
Sorry, Ms. SHOFIYA CHILMI, we can't help you with C programming, because there are so many differences, thank you.
What compiler do you use, bro? If I use Borland C++, the output should be like the command line image above.
It's easy, bro, you just wrap it in each branch with a function according to the topic. Example:
long jumlahhari(jml){
//-------------------------------jmlhr----------------------------------------
if(hr>20){
thr = hr / 20 * gj_pkk + gj_pkk;
}
else if(hr<=20){
thr= gj_pkk;
}
else {
clrscr();
cout<<" Maaf Kode Lama Kerja Anda Salah!!!"<
Don't forget, if all branches are wrapped in a function, then it must be placed outside the main function (void main), because what needs to be called in the main function are the names of the additional functions. Example:
void main(){
jumlahhari(jml);
}
the rest is up to you, happy studying, bro, good luck!
Maybe there is some incorrect syntax in the program you wrote, try including a screenshot of the error notification, bro, I'll help you debug it.
Just declare a variable for tax, for example long pjk, then create a special function to calculate tax, for example there are 3 groups subject to income tax:
long pjk(pjk){
if (jml >= 1000000){ pjk = 10/100; } //untuk pajak 10%
else if (jml >= 5000000){ pjk = 20/100; } //untuk pajak 20%
else if (jml >= 10000000){ pjk = 30/100; } //untuk pajak 30%
return pjk;
}
then call the long tax(pjk) function; in the main function for the first time (top in the main function). After that use the tax variable to reduce the total salary, for example:
jml= thr+tgol+tpddkn+tt+tsn+tlk;
long totgj = jml-(jml*pjk);
cout<< "tampilkan gaji :" << totgj;
Sorry bro, do you mean for assignments or for business? If for business, please just email, what are the criteria needed, so I can estimate the cost. But if for assignments, please discuss it in OUR FORUM
What is the error notification like? Can you show the capture? Because until now the program above can still be run, we are using Borland C++
Hii SEPTIAN FM, awesome, good job and good luck!
Hii NGAPAKERS, thank you, welcome to my blog
Yes, it is called nested if, if inside if, meaning many procedures inside the procedure. To find out about this discussion you can check it in the SITEMAP menu.
bro i want to ask for help, i have tried with the example above, but it keeps getting wrong. i need this to be collected tomorrow. can you help me??
Create an employee salary program with the program output displaying (35):
a. Number of employees
b. Employee Name Entry
c. Employee Position Selection:
- Manager
- Supervisor
- Regular Employee
- Cleaning service
d. Salary requirements: - Manager: Rp. 15,000,000
- Supervisor: Rp. 10,000,000
- Regular employee: Rp. 7,000,000
- Cleaning Service : Rp. 3,000,000
e. Marital Status & Allowance : - Married, no children yet 1 person: Rp. 2,000,000
- Married, no children yet, 2 people: Rp. 3,000,000
- Married without children more than 2 people: Rp. 4,000,000
- Single: Rp. 0
f. Overtime pay is calculated by the number of hours/month = Rp. 100,000/hour
g. Income Tax: - Amount received ≥ 20,000,000 pph = 15%
- Amount received between 10,000,000 to 20,000,000 pph = 10%
- Amount received ≤ 10,000,000 pph = 10%
- h. Total net employee salary.
- At the end of the program, a table is displayed as follows:
- https://drive.google.com/drive/folders/1jj7nDPxXwLIzOeJjSXxluXnoordw7Ubl?usp=sharing
good job guys.. happy studying guys.. keep up the spirit
C++ Payroll Program with 2 Dimensional Array
Case study:
PT. PETERNAKAN CODE provides a fixed honorarium to its contract employees of Rp. 850,000,- per month, with the following provisions:
a. Position allowance
For example: If an employee is in grade 3, he gets an allowance of 15% * 850,000
b. Education Allowance
c. Overtime Honorarium
The number of normal working hours in one month is 240 working hours. Overtime honorarium is given if the number of working hours is more than 240 hours. Excess working hours are multiplied by the overtime honorarium per hour of Rp. 2,500,- for each excess working hour in one month.
d. The program display is as follows:
Input
Output
C++ Menu Payroll 2 Dimensional Array
C++ Output Payroll 2 Dimensional Array
Source Code:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#include<cstring>
#define jumkar 100
#define datpeg 3
#define atrtunj 3
/**
*bundet.com
*C++ PENGGAJIAN DENGAN ARRAY 2 DIMENSI
*/
/*
jumkar untuk menyimpan jumlah karyawan
datpeg adalah jumlah atribut karyawan selain nama (golongan, pendidikan & lembur)
artunj adalah jumlah atribut tunjangan karyawan (jabatan, pendidikan & honor lmbur)
*/
/*
Program Menghitung Honor Karyawan Kontrak PT. PETERNAKAN CODE
oleh Yoga Asmara (12131295)
Blog : http://denmoro.blogspot.co.id/
untuk Tugas Praktikum Pemrograman Sistem
Materi Utama: 'Array'
*/
void main() {
clrscr();
cout <<"Program Hitung Honor Karyawan Kontrak \n";
cout <<"PT. PETERNAKAN CODE \n";
cout <<"\n ";
cout <<"<< tampilan input >> \n";
cout <<"\n ";
int gaji=850000; //gaji tetap bulanan setiap karyawan kontrak
int lagi = 0, i=1;
char y;
string namakaryawan[jumkar]; //nama karyawan sejumlah jumkar
int datapegawai[jumkar][datpeg];
long tunjangan[jumkar][atrtunj];
long gajitotal[jumkar];
while (lagi<1)
{
cout<<"\nNama Karyawan: "; cin>>namakaryawan[i];
cout<<"Golongan (1/2/3): "; cin>>datapegawai[i][1];
cout<<"Pendidikan (1=SMU; 2=D3; 3=S1): "; cin>>datapegawai[i][2];
cout<<"Jumlah jam kerja: "; cin>>datapegawai[i][3];
//ketentuan besarnya tunjangan jabatan berdasarkan golongan
if (datapegawai[i][1]==1)
{
tunjangan[i][1]= gaji*0.05;
}
else if(datapegawai[i][1]==2)
{
tunjangan[i][1]= gaji*0.10;
}
else if(datapegawai[i][1]==3)
{
tunjangan[i][1]= gaji*0.15;
}
//ketentuan besarnya tunjangan pendidikan berdasarkan pendidikan
if (datapegawai[i][2]==1)
{
tunjangan[i][2]= gaji*0.025;
}
else if(datapegawai[i][2]==2)
{
tunjangan[i][2]= gaji*0.05;
}
else if(datapegawai[i][2]==3)
{
tunjangan[i][2]= gaji*0.075;
}
//ketentuan besarnya gaji honor lembur berdasarkan jam kerja
if (datapegawai[i][3]>=240)
{
tunjangan[i][3]= (datapegawai[i][3]-240)*2500;
}
else
{
tunjangan[i][3]= 0;
}
//menghitung total gaji (gaji bersih) setiap karyawan
gajitotal[i] = gaji + tunjangan[i][1] + tunjangan[i][2] + tunjangan[i][3];
cout<<"\nULANGI LAGI [Y/T] ? ";
y = getche();
{
if (y=='Y'||y=='y')
lagi =- 1;
i++;
}
lagi++;
cout<<"\n";
}
clrscr();
cout <<"\n << tampilan output >> \n";
cout <<" PT. PETERNAKAN CODE \n";
cout <<"----------------------------------------------------------------\n";
cout <<"No.";
gotoxy(6,5); cout<<"Nama";
gotoxy(20,5); cout<<"Tunjangan";
gotoxy(5,6); cout<<"Karyawan";
gotoxy(20,6); cout<<"-----------------";
gotoxy(40,6); cout<<"Honor";
gotoxy(50,6); cout<<"Gaji";
gotoxy(20,7); cout<<"Jabatan";
gotoxy(28,7); cout<<"Pendidikan";
gotoxy(40,7); cout<<"Lembur";
gotoxy(50,7); cout<<"Bersih";
gotoxy(1,8); cout<<"----------------------------------------------------------------\n ";
//menghitung total gaji semua karwayan (gajikeluar)
long gajikeluar = 0;
for (int j=1;j<i;j++)
{
gotoxy(1,8+j); cout<<j; cout<<".";
gotoxy(5,8+j); cout<<namakaryawan[j];
gotoxy(20,8+j); cout<<tunjangan[j][1];
gotoxy(28,8+j); cout<<tunjangan[j][2];
gotoxy(40,8+j); cout<<tunjangan[j][3];
gotoxy(50,8+j); cout<<gajitotal[j];
gajikeluar = gajikeluar + gajitotal[j];
}
gotoxy(1,8+i); cout<<"----------------------------------------------------------------\n ";
gotoxy(5,9+i); cout<<"Total gaji yang dikeluarkan";
gotoxy(45,9+i); cout<<gajikeluar;
gotoxy(1,10+i); cout<<"----------------------------------------------------------------\n ";
getch();
}
Hope this is useful & happy learning!
Question 1
M ARIFIN 2 Dec 2016, 13:06:00 Why does the program fail when compiled? The error is in gotoxy.
Response 1
After I checked again, it turns out it still works, bro, it's normal. Maybe you're using a different compiler, bro. Above I used Borland C++