bank.cpp

Shkarkuar 517 herë. Ngarkuar më Shkurt 2012

banka
Shkarko Kthehu ne C++

/*---------------|
| ERMIR BEQIRAJ  |
*----------------|*/

#include <cstdlib>
#include <iostream>

using namespace std;

struct b{
  char emri[20];
  char mbiemri[20];
  char  id[20];
  int  pas;
  int  lek;
         }person[20];         

static int nr=0;

void admin();
void klient();
void shto();
void modifiko();

void identitet(){
   int n;
   cout<<"\t1. Admin \n";
   cout<<"\t2. Klient\n";
   cout<<"\t0. Dil\n";
   cin>>n;
   switch(n){
     case 1: admin();break;
     case 2: klient();break;
     case 0: exit(0);        
             }              
                 }
void admin(){
    system("cls");
    cout<<"\t1. Shto nje llogari\n";
    cout<<"\t2. Modifiko nje llogari\n";
    cout<<"\t3. Identitet\n";
    cout<<"\t0. Dil\n";
    int n;
    cin>>n;
    switch(n){
      case 1:shto();break;
      case 2:modifiko();break;
      case 3:identitet();break;
      case 0:exit(0);        
              }         
             }
void klient(){
    system("cls");
    cout<<"\n\tIdentifikohu  \n";
    cout<<"\tID      : ";
    int n,cash;
    char text[20];
    cin>>text;
    cout<<"\tpasword : ";
    cin>>n;
    int kontroll,temp;

    for(int i=0;i<nr;i++){
       kontroll=strcmp(text,person[i].id);
       if((kontroll==0)&&(n == person[i].pas))
          {
           temp=i;
                 system("cls");   
                 cout<<" Sucess !!!\n";
                 cout<<"1. Gjendja ne llogarine tuaj \n";
                 cout<<"2. Terheqje \n";
                 cout<<"0. Dil \n";
                 int zgjidh;
                 cin>>zgjidh;
                 
                 if(zgjidh==0)
                    exit(0);   
                 
                 if(zgjidh==1){
                 system("cls");              
                 cout<<"gjendja ne llogarine tuaj eshte : ";
                 cout<<person[temp].lek<<" Euro\n";
                 cout<<"\n\n1. Klient\n";
                 cout<<"0. Dil\n";
                  int x;
                  cin>>x;
                  if(x==1)
                  klient();
                  else
                  exit(0);
                               }
                  
                 if(zgjidh==2){
                   system("cls");              
                   cout<<endl<<"-----------------------\n";
                   cout<<"Shuma qe do terhiqni : ";
                   cin>>cash;

                   if((cash < 0)||(cash > person[temp].lek)){
                      cout<<"Shuma e kerkuar nuk mund te ofrohet ! ";
                      identitet();      }
                   else{
                     system("cls");   
                     person[temp].lek=((person[temp].lek) - cash);
                     cout<<"Ju terhoqet "<<cash<<" Euro\n";
                     cout<<"Gjendja e mbetur : "<<person[temp].lek<<" Euro";
                     cout<<endl<<"-----------------------\n";
                     cout<<"\n1. Klient\n";
                     cout<<"2. Admin\n";
                     cout<<"0. Dil\n";
                  int x;
                     cin>>x;
                  if(x==1)
                     klient();
                  if(x==2)
                     admin();
                  else
                     exit(0);   
                        }
                              } 
                   }
               }klient();
   }                              
void shto(){                    //shtojme nje llogari
    nr++;
    system("cls");
    cout<<"Emri    : ";
    cin>>person[nr-1].emri;
    cout<<"Mbiemri : ";
    cin>>person[nr-1].mbiemri;
    cout<<"ID      : ";
    cin>>person[nr-1].id;
    cout<<"password :";
    cin>>person[nr-1].pas;
    cout<<"gjendja : ";
    cin>>person[nr-1].lek;
    identitet();        
            }
                          //Modifikojme nje llogari
void modifiko(){   
   int n,c,kontroll;

   cout<<endl;
   system("cls");
   cout<<"\t1. Ndrysho gjendjen cash ";
   cout<<"\n\t2.Ndrysho llogarine \n";
   cout<<"\t0. Identitet\n";
   cin>>n;
   char temp[20];
   switch(n){
     case 1:{
          cout<<"vendosni ID e llogarise  : ";
          cin>>temp;
          for(int i=0;i<nr;i++){
            kontroll=strcmp(temp,person[i].id);
            if(kontroll==0){
              cout<<"vendosni gjendjen e re : \n";
              cin>>c;
              person[i].lek=c;            
                                 }
                             }
                                                        
                 admin(); 
                         }break;
          case 2:{
           system("cls");    
           cout<<"\nVendosni ID : ";
           cin>>temp;
           for(int i=0;i<nr;i++){
            kontroll=strcmp(temp,person[i].id);
            if(kontroll==0){
              cout<<"Emri    : ";
              cin>>person[i].emri;
              cout<<"Mbiemri : ";
              cin>>person[i].mbiemri;
              cout<<"ID      : ";
              cin>>person[i].id;
              cout<<"password :";
              cin>>person[i].pas;              
              cout<<"vendosni gjendjen e re : \n";
              cin>>c;
              person[i].lek=c;
              admin();
                              }
                                }                          
                 };break;
           default :{ 
                   cout<<"zgjedhje jo e sakte ! ";
                   admin();      }
   }
}

int main(int argc, char *argv[]){
             //therrasim klasen identitet
    identitet();
    cin.get();
    cin.get();
    return EXIT_SUCCESS;
}