Kriterlere göre maas hesaplaması

Merhaba arkadaşlar ,

Bir toplulukdaki kişilerin cinsiyet, egitim durumu(1 ile 5 arasında) ve maaş bilgileri Notepad editörünü kullanarak “anket.txt” isimli dosyada aşağıdaki şekilde yaratılmış bulunmaktadır(yaklaşık olarak 100 kayıt yaratılmıştır).

 

 

E  3   3500

K  2   1800

E  5   7500

E  4   2650

K  1  1850

E   5  3600

..

..

Bir C programı yazıp “anket.txt” isimli dosyadan bilgileri okutarak Her cinsiyet grubunun eğitim durumuna göre maaş ortalamaların aşağıdaki biçimde listeleyelim.

Öncelikle anket dosyamızı d sürücümüze ekleyelim.

#include<stdio.h>

#include<conio.h>

int main()

{

  //Değişkenler

                               char Cinsiyet;

        float Maas;

                               int Egitimdurum;

        float e1=0.00,e2=0.00,e3=0.00,e4=0.00,e5=0.00;

 

        float k1=0.00,k2=0.00,k3=0.00,k4=0.00,k5=0.00;

 

        float orte1=0.00,orte2=0.00,orte3=0.00,orte4=0.00,orte5=0.00;

 

        float ortk1=0.00,ortk2=0.00,ortk3=0.00,ortk4=0.00,ortk5=0.00;

 

        //Başlangıç değerleri

                               float eMaas[5]={0.00,0.00,0.00,0.00,0.00};

                               float kMaas[5]={0.00,0.00,0.00,0.00,0.00};

 

                FILE *anket=fopen(“d:\\anket.txt”,”r”);

 

                while(!feof(anket)){

                fscanf(anket,”%c %d %f”,&Cinsiyet,&Egitimdurum,&Maas);

                //Cinsiyetlere göre ayrım ve egitimdurumına göre maaş

                if (Cinsiyet==’E’){

                               if (Egitimdurum==1) {

                                               e1=e1+1;

                               eMaas[0]=Maas+eMaas[0];

                               } else if  (Egitimdurum==2) {

                                                               e2=e2+1;

                               eMaas[1]=Maas+eMaas[1];

                               } else if (Egitimdurum==3) {

                                                                              e3=e3+1;

                               eMaas[2]=Maas+eMaas[2];

                               }

                                                               else if (Egitimdurum==4) {

                                                                              e4=e4+1;

                                                               eMaas[3]=Maas+eMaas[3];

                               }

                                                                              else if (Egitimdurum==5) {

                                                                                                              e5=e5+1;

                               eMaas[4]=Maas+eMaas[4];

                               }

                               } else

                if (Cinsiyet=’K’){

                               if (Egitimdurum==1) {

                                               k1=k1+1;

                                               kMaas[0]=Maas+kMaas[0];

                               }

                               else if (Egitimdurum==2) {

                                               k2=k2+1;

                                               kMaas[1]=Maas+kMaas[1];

                               }

                               else if (Egitimdurum==3) {

                                               k3=k3+1;

                                               kMaas[2]=Maas+kMaas[2];

                               }

                               else if (Egitimdurum==4) {

                                               k4=k4+1;

                                               kMaas[3]=Maas+kMaas[3];

                               }

                               else if (Egitimdurum==5) {

                                               k5=k5+1;

                                               kMaas[4]=Maas+kMaas[4];

                               }

                                          }

                }

 

                fclose(anket);

                //Ortalam maaş hesaplama

                //Erkekler

                    orte1=(eMaas[0]/e1);

                               orte2=(eMaas[1]/e2);

                               orte3=(eMaas[2]/e3);

                               orte4=(eMaas[3]/e4);

                               orte5=(eMaas[4]/e5);

                               // Kadınlar

                               ortk1=(kMaas[0]/k1);

                               ortk2=(kMaas[1]/k2);

                               ortk3=(kMaas[2]/k3);

                               ortk4=(kMaas[3]/k4);

                               ortk5=(kMaas[4]/k5);

 

 

                               printf(“—————–Egitimdurum Durumlari————————-\n”);

                               printf(“———–1——–2——–3——–4——–5———-\n”);

                               printf(“ERKEK..:%4.2f, %4.2f, %4.2f, %4.2f, %4.2f\n”,orte1,orte2,orte3,orte4,orte5);

                               printf(“KADIN..:%4.2f, %4.2f, %4.2f, %4.2f, %4.2f\n”,ortk1,ortk2,ortk3,ortk4,ortk5);

                               getchar();

                return 0;

};

You may also like...

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

Bu site, istenmeyenleri azaltmak için Akismet kullanıyor. Yorum verilerinizin nasıl işlendiği hakkında daha fazla bilgi edinin.