Professional Documents
Culture Documents
Seminar 4 Z
Seminar 4 Z
1. Krijoni ne klase llogariDepozit. Perdorni nje anetar te dhene statike perqindjaInteresitVjetor per te
ruajtu perqindjen e interesit vjetor per cdo depozite. Cdo pjestar i klases ka nje te dhene private
balancaDepozites qe percakton shumen aktuale ne depozite. Krijoni nje funksion
llogaritInteresinMujor qe llogarit interesin mujor duke shumezuar balancen me
perqindjaInteresitVjetor/12, ky interes duhet te shtohet tek balancaDepozites. Krijoni nje funksion
static modifikoPerqindjenInteresit qe vendos perqindjaInteresitVjetor ne nje vlere te re. Shkruani
programin qe teston klasen e krijuar. Inicializoni dy objekte te ndryshem te klases depozita1 dhe
depozita2 me balance perkatesisht $2000.00 dhe $3000.00. Vendosni vleren e
perqindjaInteresitVjetor ne 3 perqind. Me pas llogaritni interesin mujor dhe printoni balancen e re per
cdo depozite. Me pas vendoseni perqindjaInteresitVjetor ne vleren 4 perqind dhe llogaritni interesin e
muajit pasardhes dhe printoni balancen per cdo depozite.
llogaria.h
#ifndef Llogaria
#define Llogaria
class llogariDepozit
{
public:
llogariDepozit(){}
llogariDepozit(double vlera);
~llogariDepozit(){}
static double perqindjaInteresitVjetor;
void llogaritInteresinMujor();
static void modifikoPerqindjenInteresit (double vlera);
double printoBalance() const { return balancaDepozites; }
private:
// cdo anetar i klases ka nje anetar privat qe percakton balancen aktuale te depozites
double balancaDepozites;
};
#endif
llogaria.cpp
#include "llogaria.h"
#include <iostream>
#include <iomanip>
using namespace std;
// konstruktori i kopjes per te inicializuar vlerat
llogariDepozit::llogariDepozit(double vlera)
{
balancaDepozites = vlera;
}
main.cpp
#include <cstdlib>
#include <iostream>
#include "llogaria.h"
using namespace std;
int main()
{
llogariDepozit depozita1(2000.00);
llogariDepozit depozita2(3000.00);
depozita2.llogaritInteresinMujor();
cout << "Balanca e Depozita 2 eshte: $" << depozita2.printoBalance() << "\n";
// vendos perqindjaInteresitVjetor ne 4%
llogariDepozit::modifikoPerqindjenInteresit (0.04);
// llogaritet interesi i muajit pasardhes me vleren e re te interesit dhe printohet balanca e depozites
cout<< "Interenci i muajit te dyte eshte :\n\n";
depozita1.llogaritInteresinMujor();
cout << "Balanca e Depozita 1 eshte: $" << depozita1.printoBalance() << "\n";
depozita2.llogaritInteresinMujor();
cout << "Balanca e Depozita 2 eshte: $" << depozita2.printoBalance() << "\n";
cout << endl;
return 0;
}
2
Algoritmikë dhe Programim i Avancuar Seminar 4
thyesa.h
#ifndef thyesat
#define thyesat
class Thyesat
{
public:
Thyesat(int = 0, int = 1);
Thyesat operator +(const Thyesat&);
Thyesat operator -(const Thyesat&);
Thyesat operator *(const Thyesat&);
Thyesat operator /(Thyesat&);
bool operator >(const Thyesat&) const;
bool operator <(const Thyesat&) const;
bool operator >=(const Thyesat&) const;
bool operator <=(const Thyesat&) const;
bool operator ==(const Thyesat&) const;
bool operator !=(const Thyesat&) const;
void print(void) const;
private:
int numeruesi;
int emeruesi;
void thjeshto(void);
};
#endif
thyesat.cpp
#include <iostream>
#include <cstdlib>
#include "thyesat.h"
using namespace std;
numeruesi /= pjestuesiMeMadh;
emeruesi /= pjestuesiMeMadh;
}
main.cpp
#include <iostream>
#include "thyesat.h"
using namespace std;
int main()
{
Thyesat numer1(15, 2);
Thyesat numer2(8, 6);
Thyesat vlera;
// Mbledhja
cout << "Mbledhja: ";
numer1.print();
cout << " + ";
numer2.print();
cout << " = ";
vlera = numer1 + numer2;
vlera.print();
cout << "\n";
// diferenca
cout << "Diferenca: ";
numer1.print();
cout << " - ";
numer2.print();
cout << " = ";
vlera = numer1 - numer2;
vlera.print();
cout << "\n";
//shumezimi
cout << "Shumezimi: ";
numer1.print();
6
Algoritmikë dhe Programim i Avancuar Seminar 4
cout << " x ";
numer2.print();
cout<< " = ";
vlera = numer1 * numer2;
vlera.print();
cout << "\n";
//pjestimi
cout << "Pjestimi: ";
numer1.print();
cout << " / ";
numer2.print();
cout << " = ";
vlera = numer1 / numer2;
vlera.print();
cout << "\n";
return 0;
}