public class Investmentaccount {
private String investment;
private double interestRate;
private double value;
Investmentaccount(String investment, double interestRate, double value) {
this.investment = investment;
this.interestRate = interestRate;
this.value = value;
}
public String getInvestment() {
return this.investment;
}
public void setaddValue(double value) {
this.value += value;
}
public void setToDecreaseValue(double value) {
this.value -= value;
}
public double getInterestRate() {
return this.interestRate;
}
public double getValue() {
return this.value;
}
public double returnOnInvestment() {
double numericalConverarion = this.interestRate / 100;
double returnInvestiment = ((this.value * numericalConverarion) + this.value) - this.value;
return returnInvestiment;
}
Abaixo a classe principal do programa.
public class Main {
public static void main(String[] args) {
Investmentaccount cdb = new Investmentaccount ("cdb", 15.00 , 5000 );
System.out.println(cdb.getInvestment());
cdb.setaddValue(5000);
System.out.println(cdb.getValue());
cdb.setToDecreaseValue(2000);
System.out.println(cdb.getValue());
cdb.setToDecreaseValue(4000);
System.out.println(cdb.getValue());