JAVA:How to program!!
We can use the program on our daily life.
Exspecially we major in business administration.
I think we must have some basic computer skill.
We can use it to calculate the interest with following program which I made:
import javax.swing.JOptionPane;import javax.swing.JTextArea;
import java.text.NumberFormat;
import java.util.Locale;
public class ex1 { public static void main(String arg[])
{ double amount,p=1000.0,r=0.05; String result="年\t年終餘額\n";
NumberFormat money=NumberFormat.getCurrencyInstance(Locale.TAIWAN );
JTextArea output=new JTextArea(20,40); output.setText(result);
for(int year=1;year<=10;year++) { amount=p*Math.pow(1+r,year); output.append(year+"\t"+money.format(amount)+"\n"); } JOptionPane.showMessageDialog(null,output); System.exit(0); }
}
Exspecially we major in business administration.
I think we must have some basic computer skill.
We can use it to calculate the interest with following program which I made:
import javax.swing.JOptionPane;import javax.swing.JTextArea;
import java.text.NumberFormat;
import java.util.Locale;
public class ex1 { public static void main(String arg[])
{ double amount,p=1000.0,r=0.05; String result="年\t年終餘額\n";
NumberFormat money=NumberFormat.getCurrencyInstance(Locale.TAIWAN );
JTextArea output=new JTextArea(20,40); output.setText(result);
for(int year=1;year<=10;year++) { amount=p*Math.pow(1+r,year); output.append(year+"\t"+money.format(amount)+"\n"); } JOptionPane.showMessageDialog(null,output); System.exit(0); }
}

0 Comments:
Post a Comment
<< Home