运行时,结果就像没有输入值一样。我希望有人或所有人可以审查代码和批评。
package practice_array_tables;
import javax.swing.*;
public class Practice_Array_Tables {
public static void main(String[] args) {
//Variables
String Principal, Rate, Time;
//Prompt user for input via JOptionPane.showInputDialog
Principal = JOptionPane.showInputDialog(" Enter Principle Amount. ");
//Enter Rate.
Rate = JOptionPane.showInputDialog(" Enter Rate, i.e 0.10 ");
//Enter Time
Time = JOptionPane.showInputDialog(" Enter Time ");
//Parse String to Int.
int p = Integer.parseInt(Principal);
int r = Integer.parseInt(Rate);
int t = Integer.parseInt(Time);
//Compute Compound Interest.\
double CompoundInterest = p * Math.pow((1+r / 100), t );
double c = CompoundInterest;
//Print results to JOptionPane.showMessageDialog.
JOptionPane.showMessageDialog(null, " your answer " + c);
}
}