Good morning everyone,
I would like you to help me, I am doing a simple program of a console account, the problem is that I ask the user name and type of operation to perform, if it is withdrawal or consigning the program must perform an action. If it is consign the program asks for the amount and and adds it to the account balance, however I do not know what the error is but it does not print it, it does not add the amount to the balance in account and it only prints the balance, help please, I send the code , the truth is I'm very new programming.
This is the account class, the other is the main, but in the only print and ask for the data, it has no relevance.
public class Cuenta {
private String titular;
private double saldo;
private double monto;
private char ingresar = 'C';
private char retirar = 'R';
public Cuenta() { // constructor con las variables sobrecargadas
titular=null;
saldo=500.0;
monto=0.0;
}
public Cuenta(String titular, double saldo, double monto) { // constructor con las variables por parametro
}
public double ingresar(double monto) {
/*if(monto<0) {
saldo=saldo;
}else {
this.saldo=saldo+monto;
}*/
this.saldo=saldo+monto;
return saldo;
}
public double retirar(double monto) {
if(saldo<monto) {
saldo=0.0;
}else {
this.saldo=saldo-monto;
}
return saldo;
}
public void setTitular(String titular) {
this.titular=titular;
}
public String getTitular() {
return titular;
}
public void setMonto(double monto) {
this.monto=monto;
}
public double getMonto() {
return saldo;
}
public void setOperacion(char operacion) {
if(operacion == ingresar) {
ingresar(monto);
}
if(operacion == retirar) {
retirar(monto);
}
}
public String toString() {
return "Cuenta = "+getTitular()+" Saldo = "+getMonto();
}
}