運行結果就好像沒有輸入值。 我希望有人或所有人都可以評論代碼和評論。簡單平均程序未得到計算結果
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);
}
}
謝謝你,我應該記住,從我的介紹到Java類,再次感謝隊友。 – user2230361