
public class PortaMoedas {

	private double total;                  // valor total
	private int q5, q10, q25, q50, q1;     // quantidade de cada moeda 
	
	
	// construtor
	public PortaMoedas(){
		total = 0.0;
		q5 = 0;
		q10 = 0;
		q25= 0;
		q50 = 0;
		q1 = 0;
	}
	
	
	public void add5Cents(int quant){
		total += 0.05 * quant;
		q5 += quant;
	}
	
	public void add10Cents(int quant){
		total += 0.10 * quant;
		q10 += quant;
	}
	
	public void add25Cents(int quant){
		total += 0.25 * quant;
		q25 += quant;
	}
	
	public void add50Cents(int quant){
		total += 0.50 * quant;
		q50 += quant;
	}
	
	public void add1Real(int quant){
		total += 1 * quant;
		q1 += quant;
	}
	
	// retorna o valor total existente no porta moedas
	public double getTotal(){
		return total;
	}
	
	// lista todas as moedas existentes
	public void listarMoedas(){
		System.out.println("===== Moedas existentes no Porta-Moedas =====");
		System.out.println(" 5 centavos = " + q5 +
						   "\n10 centavos = " + q10 +
						   "\n25 centavos = " + q25 +
						   "\n50 centavos = " + q50 +
						   "\n1 real      = " + q1);
	}
	
	
	// Testa o porta-moedas
	public static void main(String[] args) {
		
		PortaMoedas cofrinho = new PortaMoedas();
		
		cofrinho.add1Real(5);
		cofrinho.add50Cents(3);
		cofrinho.add25Cents(8);
		cofrinho.add10Cents(4);
		cofrinho.add5Cents(17);
		
		cofrinho.listarMoedas();
		System.out.println("\nValor total: R$ " + cofrinho.getTotal());

	}

}
