Untitled
unknown
plain_text
3 years ago
1.9 kB
9
Indexable
#include <iostream>
#include "util.h"
using namespace std;
class Donativo { //El monto Donado
private:
float monto;
public:
//constructor
Donativo() { monto = 0; }
Donativo(float m) {
monto = m;
}
//destructor
~Donativo() {}
//friend
friend class FondoEscolar;//clase base Donativo, se amiga de clase derivada FondoEscolar
//Metodo Get y Set
float getMonto() { return monto; }
float setMonto(float mto) { monto = mto; }
//metodo
void pedirDonacion() {
cout << "Ingrese Donacion a Realizar (monto S/.): "; cin >> monto;
}
};
class FondoEscolar {
private:
float gIncial, gPrimaria, gSecun;
public:
//constructor
FondoEscolar() {
gIncial = 0; gPrimaria = 0; gSecun = 0;
}
FondoEscolar(float val1, float val2, float val3)
{
gIncial = val1; gPrimaria = val2; gSecun = val3;
}
//destructor
~FondoEscolar() {}
//metodo Get y Set
float getInicial() { return gIncial; }
void setInicial(float a) { gIncial = a; }
float getPrimaria() { return gPrimaria; }
void setPrimaria(float a) { gPrimaria = a; }
float getSecun() { return gSecun; }
void setSecun(float a) { gSecun = a; }
//metodo
void distribuir(Donativo D) {
if (D.monto < 5000)
gSecun = D.monto;
if (D.monto >= 5000 && D.monto <= 10000)
{
gPrimaria = 0.4 * D.monto;
gSecun = 0.6 * D.monto;
}
if (D.monto > 10000)
{
gPrimaria = 0.35 * D.monto;
gSecun = 0.45 * D.monto;
gIncial = 0.20 * D.monto;
}
}
};
#ifdef MAIN4
int main() {
Donativo Don;
Don.pedirDonacion();
FondoEscolar Fondo;
Fondo.distribuir(Don);
//Mostrando informacion
cout << "Al Nivel Inicial le Asignaron: S/. " << Fondo.getInicial() << endl;
cout << "Al Nivel Primario le Asignaron: S/. " << Fondo.getPrimaria() << endl;
cout << "Al Nivel Secundaria le Asignaron: S/. " << Fondo.getSecun() << endl;
return 0;
}
#endif // MAIN4
Editor is loading...