Ameliorate
May 17th, 2007, 05:51 AM
I have a problem with this class:
package chapter5;
import java.text.NumberFormat;
import java.util.Locale;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
public class Interest {
public static void main(String args[])
{
double amount, principal = 1000.0, rate = 0.05;
NumberFormat moneyFormat = NumberFormat.getCurrencyInstance(Locale.US);
JTextArea outputArea = new JTextArea();
outputArea.setText("Year\tAmount on deposit\n");
for(int year = 1; year<=10;year++)
{
amount = principal*Math.pow(1.0+rate, year);
outputArea.append(year+"\t"+moneyFormat.format(amount)+"\n");
}
JOptionPane.showMessageDialog(null, outputArea, "Interest over 10 Years", JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
there are no errors at compile time. However, at runtime I get this error and i dont know why:
Exception in thread "main" java.lang.IllegalArgumentException: The currency code, $, is not supported.
at java.util.Currency.getInstance(libgcj.so.70)
at java.text.DecimalFormatSymbols.getCurrency(libgcj. so.70)
at java.text.DecimalFormat.getCurrency(libgcj.so.70)
at java.text.NumberFormat.getCurrencyInstance(libgcj. so.70)
at chapter5.Interest.main(Interest.java:11)
and the eclipse console displays this in the headbar:
<terminated> Interest [Java Application] /usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/bin/java
Is there a problem with the gcj? ^^^
package chapter5;
import java.text.NumberFormat;
import java.util.Locale;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
public class Interest {
public static void main(String args[])
{
double amount, principal = 1000.0, rate = 0.05;
NumberFormat moneyFormat = NumberFormat.getCurrencyInstance(Locale.US);
JTextArea outputArea = new JTextArea();
outputArea.setText("Year\tAmount on deposit\n");
for(int year = 1; year<=10;year++)
{
amount = principal*Math.pow(1.0+rate, year);
outputArea.append(year+"\t"+moneyFormat.format(amount)+"\n");
}
JOptionPane.showMessageDialog(null, outputArea, "Interest over 10 Years", JOptionPane.PLAIN_MESSAGE);
System.exit(0);
}
}
there are no errors at compile time. However, at runtime I get this error and i dont know why:
Exception in thread "main" java.lang.IllegalArgumentException: The currency code, $, is not supported.
at java.util.Currency.getInstance(libgcj.so.70)
at java.text.DecimalFormatSymbols.getCurrency(libgcj. so.70)
at java.text.DecimalFormat.getCurrency(libgcj.so.70)
at java.text.NumberFormat.getCurrencyInstance(libgcj. so.70)
at chapter5.Interest.main(Interest.java:11)
and the eclipse console displays this in the headbar:
<terminated> Interest [Java Application] /usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/bin/java
Is there a problem with the gcj? ^^^