Untitled

 avatar
unknown
plain_text
2 years ago
1.6 kB
5
Indexable
#include <iostream>
using namespace std;
class Donativo { //El monto Donado
private:
	float monto = 0;
public:
	Donativo(){}
	Donativo(float m) {
		monto = m;}
	~Donativo() {}
	friend class FondoEscolar;
	float getMonto() { return monto; }
	float setMonto(float mto) { monto = mto; }
	void pedirDonacion() {
		do
		{
			cout << "Ingrese Donacion a Realizar (monto S/.): "; cin >> monto;} 
		while (!(monto >= 0));
	}
};
class FondoEscolar {
private:
	float gIncial=0, gPrimaria = 0, gSecun = 0;
public:
	FondoEscolar() {}
	FondoEscolar(float val1, float val2, float val3)
	{	gIncial = val1; gPrimaria = val2; gSecun = val3;}
	~FondoEscolar() {}
	float getInicial() { return gIncial; }
	float getPrimaria() { return gPrimaria; }
	float getSecun() { return gSecun; }
	void distribuir(Donativo D) {
		if (D.monto < 5000) gSecun = D.monto;
		else if (D.monto >= 5000 && D.monto <= 10000)
		{
			gPrimaria = 0.4 * D.monto;
			gSecun = 0.6 * D.monto;
		}
		else 
		{
			gPrimaria = 0.35 * D.monto;
			gSecun = 0.45 * D.monto;
			gIncial = 0.20 * D.monto;
		}
		cout << "Al Nivel Inicial le Asignaron: S/. " << getInicial() << " , es decir, el " << (100 * getInicial() / D.monto) << "% " << endl;
		cout << "Al Nivel Primario le Asignaron: S/. " << getPrimaria() << " , es decir, el " << (100 * getPrimaria() / D.monto) << "% " << endl;
		cout << "Al Nivel Secundaria le Asignaron: S/. " << getSecun() << " , es decir, el " << (100 * getSecun() / D.monto) << "% " << endl;
	}
};
int main() {
	Donativo Don;
	Don.pedirDonacion();
	FondoEscolar Fondo;
	Fondo.distribuir(Don);
	system("pause>0");
}

Editor is loading...