- 25 Kas 2022
- 8
- 6
C++:
#include <iostream>
#include <string>
#include <conio.h>
#define MAX 150
#define MAX2 15
#define MAX3 10
using namespace std;
void gorevli_menu();
void ana_menu();
class Ogrenci {
public:
string ad,soyad;
int numara,vize,final;
double ort;
Ogrenci() {};
void yeni_kayit(string,string,int);
} ogrenciler[MAX], ogrenciler1[MAX3];
void Ogrenci::yeni_kayit(string a, string s, int n) {
ad = a;
soyad = s;
numara = n;
}
class Ogretmen {
public:
string ogretmen_ad, ogretmen_soyad, sifre, ders;
int ogretmen_no;
void yeni_kayit1(int,string,string,string,string);
void ogretmen_menu();
} ogretmenler[MAX2];
void Ogretmen::yeni_kayit1(int n, string a, string s, string d, string pass) {
ogretmen_no = n;
ogretmen_ad = a;
ogretmen_soyad = s;
ders = d;
sifre = pass;
}
void Ogretmen::ogretmen_menu() {
int secim,n;
static double toplam;
static int d = -1; // indis olarak kullanılacağı için static olarak tanımlandı.
// fonksiyon her çağırıldığında önceki değerini okur.
system("cls");
cout << "Ogretmen Not Sistemi" << endl;
cout << "---------------------" << endl;
cout << " 1. Not Girisi" << endl;
cout << " 2. Sinif Not Ortalamasi" << endl;
cout << " 3. Ogrenci Listesi" << endl;
cout << " 4. Ana Menu" << endl;
cout << "\n Seciminizi giriniz: ";
cin >> secim;
switch(secim) {
case 1:
system("cls");
cout << "Notunu gireceginiz ogrencinin numarasini giriniz: " << endl;
cin >> n;
for(int c=0; c<150; c++) {
if(ogrenciler[c].numara == n) {
system("cls");
cout << "Vize notunu giriniz: ";
cin >> ogrenciler[c].vize;
cout << "Final notunu giriniz: ";
cin >> ogrenciler[c].final;
cout << "\nIslem Basarili!" << endl;
d++;
ogrenciler[c].ort = double(ogrenciler[c].vize * 0.3 + ogrenciler[c].final * 0.7);
ogrenciler1[d] = ogrenciler[c]; // seçili öğretmenin dersini alan öğrenciler ayrı bir nesne dizisine alınıyor.
cout << "\n\n";
system("pause");
ogretmen_menu();
}
}
cout << "Ogrenci Bulunamadi!\n" << endl;
system("pause");
ogretmen_menu();
break;
case 2:
system("cls");
cout << "Sinifin Not Ortalamasi: ";
if(d<0) {
cout << "Bu dersi alan ogrenci yok." << endl;
system("pause");
ogretmen_menu();
} else {
for(int x=0; x<=d; x++) {
toplam += ogrenciler1[x].ort; // tum elemanlarin ortalamalari toplaniyor.
}
cout << toplam / (d+1) << endl << endl;
system("pause");
ogretmen_menu();
}
break;
case 3:
system("cls");
for(int x=0; x<=d; x++) {
for(int y=0; y<=d; y++) {
if(ogrenciler1[x].numara == ogrenciler[y].numara) { // buradaki if yapisi ogrencinin gorevli tarafindan silinmesi durumunda burada notunun gosterilmemesini saglar.
cout << "Ad: " << ogrenciler1[x].ad << "\t Soyad: " << ogrenciler1[x].soyad << "\t Numara: " << ogrenciler1[x].numara << "\t Ortalama: " << ogrenciler1[x].ort << endl << endl;
}
}
}
system("pause");
ogretmen_menu();
break;
case 4:
system("cls");
ana_menu();
}
}
int main() {
system("title Okul Otomasyon Sistemi");
ana_menu();
return 0;
}
void ana_menu() {
system("cls");
int secim, b, num;
string sifre, k_id, k_sifre;
cout << "Ana Menu" << endl;
cout << "----------------" << endl;
cout << " 1. Gorevli Girisi" << endl;
cout << " 2. Ogretmen Girisi" << endl;
cout << " 3. Cikis" << endl;
cout << "\nSeciminizi Giriniz: ";
cin >> secim;
switch(secim) {
case 1:
system("cls");
cout << "Kullanici Adi: ";
cin >> k_id;
if(k_id == "1") {
cout << "Sifre: ";
cin >> k_sifre;
if(k_sifre == "1") {
gorevli_menu();
} else {
cout << "Sifre Yanlis!\n" << endl;
system("pause");
ana_menu();
}
} else {
cout << "Kullanici Adi Yanlis!\n" << endl;
system("pause");
ana_menu();
}
break;
case 2:
system("cls");
cout << "Numaranizi Girin: ";
cin >> num;
for(b=0; b<15; b++) {
if(ogretmenler[b].ogretmen_no == num) {
cout << "Sifre Girin: ";
cin >> sifre;
if(ogretmenler[b].sifre == sifre) {
cout << "Sifre Dogru!\n" << endl;
system("pause");
ogretmenler[b].ogretmen_menu();
} else {
cout << "Sifre Yanlis!\n" << endl;
system("pause");
ana_menu();
}
} else {
cout << "Numara Yanlis!\n" << endl;
system("pause");
ana_menu();
}
}
break;
case 3:
exit(0);
default:
ana_menu();
}
}
void gorevli_menu() {
int secim, no, aranan;
static int numara=0, i=-1, a=-1;
string ad, soyad, ders, s;
system("cls");
cout << "Gorevli Menusu" << endl;
cout << "----------------" << endl;
cout << " 1. Yeni Ogrenci Kayit" << endl;
cout << " 2. Ogrenci Kayit Sil" << endl;
cout << " 3. Ogrenci Kayit Listele" << endl;
cout << " 4. Yeni Ogretmen Kayit" << endl;
cout << " 5. Ogretmen Kayit Sil" << endl;
cout << " 6. Ogretmen Listele" << endl;
cout << " 7. Ana Menu" << endl;
cout << "\n Seciminizi giriniz: ";
cin >> secim;
switch(secim) {
case 1:
system("cls");
cout << "Yeni ogrencinin adini girin: ";
cin >> ad;
cout << "Yeni ogrencinin soyadini girin: ";
cin >> soyad;
cout << "Yeni ogrencinin numarasini girin: ";
cin >> no;
i++; // indis 1 arttırıldı.
ogrenciler[i].yeni_kayit(ad,soyad,no);
cout << "Islem basarili! Yeni ogrenci kaydi olusturuldu.\n" << endl;
system("pause");
gorevli_menu();
break;
case 2:
system("cls");
if(i<0) {
cout << "Kaydi silinecek ogrenci yok.\n" << endl;
system("pause");
gorevli_menu();
} else {
cout << "Kaydi silinecek ogrencinin numarasini girin: ";
cin >> aranan;
for(int j=0; j<=i; j++) {
if(ogrenciler[j].numara == aranan) {
for(int k=j; k<i; k++) {
ogrenciler[k] = ogrenciler[k+1];
cout << "Kayit Silindi!\n" << endl;
i--;
system("pause");
gorevli_menu();
}
}
}
cout << "Kayit Bulunamadi!\n" << endl;
system("pause");
gorevli_menu();
}
break;
case 3:
system("cls");
if(i<0) {
cout << "Ogrenci kaydi yok.\n" << endl;
system("pause");
gorevli_menu();
} else {
cout << "OGRENCI NO.\tOGRENCININ ADI ve SOYADI" << endl;
cout << "===============================================" << endl;
for(int j=0; j<=i; j++) {
cout << ogrenciler[j].numara << "\t\t" << ogrenciler[j].ad << " " << ogrenciler[j].soyad << endl;
cout << "-----------------------------------------------" << endl;
}
cout << "===============================================" << endl;
}
system("pause");
gorevli_menu();
break;
case 4:
system("cls");
cout << "Yeni ogretmenin adini girin: ";
cin >> ad;
cout << "Yeni ogretmenin soyadini girin: ";
cin >> soyad;
cout << "Bransi: ";
cin >> ders;
cout << "Ogretmen girisinde kullanilacak sifre: ";
cin >> s;
a++; // indis 1 arttirildi.
numara++; // ogretmen numarasi her giriste otomatik artiyor.
ogretmenler[a].yeni_kayit1(numara,ad,soyad,ders,s);
cout << "\nIslem basarili! Yeni ogretmen kaydi olusturuldu.\n" << endl;
system("pause");
gorevli_menu();
break;
case 5:
system("cls");
if(a<0) {
cout << "Kaydi silinecek ogretmen yok.\n" << endl;
system("pause");
gorevli_menu();
} else {
cout << "Kaydi silinecek ogretmenin numarasini girin: ";
cin >> aranan;
for(int j=0; j<=a; j++) {
if(ogretmenler[j].ogretmen_no == aranan) {
for(int k=j; k<a; k++) {
ogretmenler[k] = ogretmenler[k+1];
cout << "Kayit Silindi!\n" << endl;
system("pause");
gorevli_menu();
}
}
}
cout << "Kayit Bulunamadi!\n" << endl;
system("pause");
gorevli_menu();
}
break;
case 6:
system("cls");
if(a<0) {
cout << "Ogretmen Kaydi Bulunamadi!\n" << endl;
system("pause");
gorevli_menu();
} else {
cout << "NUMARA\t\tOGRETMENIN ADI ve SOYADI\tBRANSI" << endl;
cout << "==================================================" << endl;
for(int j=0; j<=a; j++) {
cout << ogretmenler[j].ogretmen_no << "\t\t" << ogretmenler[j].ogretmen_ad << " " << ogretmenler[j].ogretmen_soyad << "\t\t" << ogretmenler[j].ders << endl;
cout << "--------------------------------------------------" << endl;
}
cout << "==================================================" << endl;
}
system("pause");
gorevli_menu();
break;
case 7:
ana_menu();
break;
default:
cout << "Hata!!" << endl;
gorevli_menu();
break;
}
}