当我运行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(字符串[]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) );
}
暂无答案!
目前还没有任何答案,快来回答吧!