//STARTING OF CODING
//CLASS FIXED INVESTMENT
public class FixedInvestment
{
//PRIVATE DATA VALUE
private double depositAmount=1000;//STORE DEFAULT DEPOSIT AMOUNT DATA
private double annualInterestRate=0.05;//STORE DEFAULT INTEREST RATE DATA
private int numberOfYears=1;//STORE DEFAULT YEAR DATA
public FixedInvestment()//CONSTRUCTOR WITHOUT PERIMETER
{
//DEFAULT CONSTRUCTOR
//EMPTY IT
}
//CONSTRUCTOR WITH PERIMETER,TO SET THE FIXED INVESTMENT
//PUBLIC DATA VALUE
public FixedInvestment(double depositAmount,double annualInterestRate,int numberOfYears)
{
//USED "THIS" REFERENCE TO MAKE SURE THE INSTANCE VARIABLE POINT TO THE CORRECT OBJECT
this.depositAmount=depositAmount;
this.annualInterestRate=annualInterestRate;
this.numberOfYears=numberOfYears;
}
//METHOD TO RETURN THE DEPOSIT AMOUNT
//POSTCONDITION:THE VALUE OF DEPOSIT AMOUNT IS RETURNED
public double getdepositAmount()
{
return depositAmount;
}
//METHOD TO RETURN THE ANNUAL INTEREST RATE
//POSTCONDITION:THE VALUE OF ANNUAL INTEREST IS RETURNED
public double getannualInterestRate()
{
return annualInterestRate;
}
//METHOD TO RETURN THE NUMBER OF YEARS
//POSTCONDITION:THE NUMBER OF YEARS IS RETURNED
public int getnumberOfYears()
{
return numberOfYears;
}
//METHOD TO RETURN THE TOTAL RETURN
//POSTCONDITION:THE VALUE OF TOTAL RETURN IS RETURNED
public double getTotalReturn()
{
//THE FORMULA OF TOTAL RETURN
return depositAmount*(1+annualInterestRate)*(numberOfYears*12);
}
//MAIN OF THE PROGRAM
public static void main(String[]args)
{
FixedInvestment NewFixedInvestment=new FixedInvestment(10000,0.045,3);//THE DATA DEPOSIT AMOUNT,ANNUAL INTEREST RATE AND YEARS NEEDED
FixedInvestment NewFixedInvestment2=new FixedInvestment();
System.out.println("total return= " + NewFixedInvestment.getTotalReturn());//PRINT THE TOTAL RETURN VALUE
//END MAIN
}
}
//END OF PROGRAMMING~
//ALHAMDULILLAH,DA SIAP!
//THANK YOU MA'AM FOR THE LESSON
BUKAN USER INPUT PROGRAM....
7 comments:
pergghh,, bro,,, mantap la coding,,
bley la kawan menuntut ngan mu ni,
kawan pon baru basis2 je ni,,,
baru pandai nak guna JOptionPane je
EP2 - Aku Seorang Blogger
huhuhuhu, bleh tlg sy plak yg wat programing..
bhs ruby
farid.. aku bru blajo basic... saje nak share mne tawu bleh berguna.. kita exchange ilmu... bru blogging x buang masa.
shahsyaz.. bahasa apa?
woi2,,membe yg tlong ltak comment nyh jgn lupe plak,, nak gak dpt name~hahaha
bro, ini utk apa?
java programming
Post a Comment