关于java中JOption的问题,谢谢!
1.
public class Repaid1 {
//Declare the variables
private double money, repaid;
//Create constructor
public Repaid1(){
}
//compute method
public void compute(){
repaid = money * 0.03 + money;
}
//Getter and setter
public void setMoney(double money){this.money = money;}
public double getMoney() {return money;}
public double getRepaid() {return repaid;}
}
2.
import org.w3c.dom.events.MutationEvent;
import javax.swing.JOptionPane;
public class RepaidApp1 {
public static void main(String[] args) {
//Declare variables
double money, repaid;
//Declare and create object
Repaid myR = new Repaid();
//input
repaid = Integer.parseInt(JOptionPane.showInputDialog(null,"Please enter the money u borrowed from your sister"));
myR.setRepaid(repaid);
//process
myR.compute();
//output
repaid = myR.getRepaid();
JOptionPane.showMessageDialog(null,"money: " + money + ", repaid: " + repaid);
}
}
1.的最后一行报错,是由于2.的setRepaid和getRepaid错误,看了半天不知道错在哪了QuQ,求解,多谢了!