Hi all,
Trust all is well.
I am currently attending an introduction to java course and need to present my final assignment by the end of the month. The assignment consists of a java program that is able to calculate the amount of money that the bank can give you for your home loan, on the basis of the amount of money you (an your partner) earn, the age and the amount of years. The amount of money that the bank will give you is 33% of your total income, but that amount includes also a 3% rate of interest.
I have made some code within a JFrame, (which for most of you is quite straight forward), and right now I cannot get the underneath to work:
private void btn_Get_QuoteActionPerformed(java.awt.event.Action Event evt) {
int txt_Age_Int = 0;
int txt_SpouseAge_Int = 0;
double txt_Monthly_Income_Int = 0.0;
double txt_Spouse_Monthly_Income_Int = 0.0;
int Ret_Age = 65;
int Loan_Repay_Years = 0;
double Total_Income = 0.0;
if((rbtn_Single.isSelected()) || (txt_Age_Int > txt_SpouseAge_Int))
{
try
{
txt_Monthly_Income_Int = Double.parseDouble(txt_Monthly_Income.getText());
txt_Age_Int = Integer.parseInt(txt_Age.getText());
}
catch (NumberFormatException e)
{
JOptionPane.showMessageDialog(null, "Numeric Values ONLY", "Error", JOptionPane.CANCEL_OPTION);
}
Total_Income = txt_Monthly_Income_Int;
Loan_Repay_Years = (Ret_Age - txt_Age_Int);
}
else if ((rbtn_Married.isSelected()) && (txt_SpouseAge_Int > txt_Age_Int))
{
try
{
txt_Spouse_Monthly_Income_Int = Double.parseDouble(txt_Spouse_Income.getText());
txt_SpouseAge_Int = Integer.parseInt(txt_SpouseAge.getText());
}
catch (NumberFormatException e)
{
JOptionPane.showMessageDialog(null, "Numeric Values ONLY", "Error", JOptionPane.CANCEL_OPTION);
}
Total_Income = (txt_Spouse_Monthly_Income_Int) + (txt_Monthly_Income_Int);
Loan_Repay_Years = (Ret_Age - txt_SpouseAge_Int);
}
String Outmessage = " Years of Repayment " + Loan_Repay_Years + "\n" +
"\n Total Income is " + Total_Income;
JOptionPane.showMessageDialog(null,Outmessage, "Qoutation", JOptionPane.INFORMATION_MESSAGE);
}
It looks like the code is totally ignoring the 'else if' statement and reporting nothing when the married button is selected.
Could you give me some help please ? And maybe even any ideas of how to develop such assignment, in terms of whether creating other classes, or use some forms of functions and methods?
Regards
The Newbie