public int efetuaSaque(int valor) { if (valor > getSaldo()) { return 0; // Retorna se não há saldo suficiente. } int tmp = valor; while (tmp > 100 && notas100 > 0) { tmp -= 100; notas100--; } while (tmp > 50 && notas50 > 0) { tmp -= 50; notas50--; } while (tmp > 20 && notas20 > 0) { tmp -= 20; notas20--; } while (tmp > 10 && notas10 > 0) { tmp -= 10; notas10--; } while (tmp > 5 && notas5 > 0) { tmp -= 5; notas5--; } while (tmp > 0 /*&& notas1 > 0*/) { tmp -= 1; notas1--; } return valor; // Retorna o valor do saque. }