You are on page 1of 3

#include <iostream> //Importojme librarite perkatese

#include <limits>
#include <iomanip>
#include <string>

using namespace std;

class Energjia_Elektrike
{
float sasiaKwH; //Deklarojme antaret private te klases
char emri[20],mbiemri[20];
string llojKons;
public: //Antaret public te klases(funksionet)
void data() //Funksion per te marre te dhenat nga
perdoruesi
{
cout<<"\n Vendos emrin dhe mbiemrin : ";
cin>>emri>>mbiemri;
cout<<"\n Lloji i konsumatorit :";
cin>>llojKons;
cout<<"\n Vendos sasine ne kwH : ";

cin>>sasiaKwH;
while(1) //Procedure per te kontrolluar te
dheant hyrese.
{
if(cin.fail())
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n' );
cout<<"Vendosni te dhena te lejuara!"<<endl;
cin>>sasiaKwH;
}
if(!cin.fail())
break;
}

}
void printo_faturen();
};
void Energjia_Elektrike::printo_faturen() //Funksioni per llogaritjen e
shumes per te paguar
{
int fatura=0;
if(llojKons =="Familjar" || llojKons == "familjar" ) {

if(sasiaKwH<=300)
fatura=(sasiaKwH*7)*1.2;

else
fatura=( 300*7+(sasiaKwH-300)*13)*1.2;

cout<<"|---------------------------------------------------------------------------
------------|"<<endl; //Pjesa grafike
cout<<setw(15)<<emri
<<setw(15)<<mbiemri<<"("<<llojKons<<")"<<setw(16)<<"----->Shuma per te paguar =
"<<fatura<<"\t"<<endl;
cout<<"|---------------------------------------------------------------------------
------------|"<<endl;
cout<<endl;
}
else{
if(sasiaKwH<=300)
fatura=sasiaKwH*13*1.2;

else
fatura=(300*11+(sasiaKwH-300)*15)*1.2;

cout<<"|---------------------------------------------------------------------------
------------|"<<endl;

cout<<setw(15)<<emri<<setw(15)<<mbiemri<<"("<<llojKons<<")"<<setw(16)<<"-------
>Shuma per te paguar = "<<fatura<<"\t"<<endl;

cout<<"|---------------------------------------------------------------------------
------------|"<<endl;
cout<<endl;
}
}
int main()
{ cout<<"***************************************************** OSSHE
***********************************************************"<<endl;

int vazhdo = 0; //Kodi per te vebdosur nese duam te qendrojme akoma ne


program
do{
Energjia_Elektrike e[10]; //Krijojme objekt nga klasa
Energjia_Elektrike.
int cnt;
cout<<"\n Numri i konsumatoreve te marre ne shqyrtim : ";

cin>>cnt; //Procedure per kotrollin e te dhenave hyrese


while(1)
{
if(cin.fail())
{
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(),'\n');
cout<<"Ju keni vendosur numrin gabim.Ju lutemi,vendoseni perseri numrin!"<<endl;
cin>>cnt;
}
if(!cin.fail())
break;
}

for(int i=0; i<cnt; i++)


e[i].data(); //Therrasi ne main funksionin per futjen e te
dhenave nga perdoruesi.
for(int i=0; i<cnt; i++)
e[i].printo_faturen();//Therrasim funksionin per te afishuar ne
ekran faturen.

cout<<"JU FALEMIDERIT!"<<endl;
cout << "A deshironi te qendroni ne program?" << endl; //Kodi per te
vebdosur nese duam te qendrojme akoma ne program
cout<<"Shtypni 1 per te qendruar dhe 0 per tu larguar: ";
cin>> vazhdo;
} while (vazhdo != 0);
return 0;
}

You might also like