问题描述
当我运行它时,我刚刚完成了Java代码,它不输出任何值。 我有两个类,一个是使用jOption输入值的类,另一个是使用第一类输入值来计算利息的类。
第1类:
public class Employee_Details {
String custName;
String custNuum;
String priice;
String Month;
int custNum;
double price;
int reMonth;
double total;
double reAmount;
public void getDetails (){
Finance_Period fin1 = new Finance_Period();
custName = JOptionPane.showInputDialog("Please enter Customer Name");
custNuum = JOptionPane.showInputDialog("Please enter Customer Number");
custNum = Integer.parseInt(custNuum);
priice = JOptionPane.showInputDialog("Please enter price of product");
price = Double.parseDouble(priice);
Month = JOptionPane.showInputDialog("Please enter number of repayment months");
reMonth = Integer.parseInt(Month);
reAmount = price/reMonth;
if (reMonth >3){
fin1.getInterest();
}
else {
total = price;
JOptionPane.showMessageDialog(null,"Customer Name: " + custName + "\n" + "Customer Conatct: " + custNum + "\n" + "Product Amount: " + "R"+price + "\n" + "Repayment Months: " + reMonth + "\n" +"Monthly Repayments: " + "R" +reAmount + "\n" + "Total Due: " + "R" + total );
}
}
}
第二堂课
public class Finance_Period {
double interest;
String name;
int num;
double product;
double amount;
public double getInterest(){
Employee_Details cust1 = new Employee_Details();
interest = (0.25 * cust1.reAmount) + cust1.reAmount;
JOptionPane.showMessageDialog(null,"Customer Name: " + cust1.custName+ "\n" + "Customer Conatct: " + cust1.custNum + "\n" + "Product Amount: " + "R"+cust1.price + "\n" + "Repayment Months: " + cust1.reMonth + "\n" +"Monthly Repayments: " + "R" + cust1.reAmount + "\n" + "Total:" + "R" + (cust1.reAmount + interest) );
return interest;
在第一堂课中,有一个if语句,如果还款月数大于3,则运行其他方法,一旦我输入的数字大于3,它将运行getinterest方法,但输出为:
我认为我没有正确链接这两个类,但是我不知道该怎么做, 我似乎在这里找不到逻辑错误,请帮帮我
这是我的主要课程
public static void main(String [] args){
Employee_Details cust1 = new Employee_Details();
cust1.getDetails();
Finance_Period fin1 = new Finance_Period();
JOptionPane.showMessageDialog(null,"Customer Name: " + cust1.custName+ "\n" + "Customer Conatct: " + cust1.custNum + "\n" + "Product Amount: " + "R"+cust1.price + "\n" + "Repayment Months: " + cust1.reMonth + "\n" +"Monthly Repayments: " + "R" + cust1.reAmount + "\n" + "Total:" + "R" + (cust1.reAmount + fin1.interest) );
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)