I am trying to learn Java programming and I am trying to figure out how to call a class to write a larger program. I have included the small part of the program that I am trying to get to work but I keep getting a compiler error. Can anyone help me figure this out. I have also copied in the error that I am getting from TextPad when I try to compile this.
************************************************** ************************************************** **************************
import javax.swing.JOptionPane;
import java.text.NumberFormat;
public class Chapter7Prog1RandyHaupert
{
public static void main (String [] args)
{
int quarters, dimes, nickels, pennies;
double totalamount = 0;
String input = JOptionPane.showInputDialog (null, "How many quaters do you have. " );
quarters = Integer.parseInt (input);
quarters = Coins.getQuarters (dimes);
}
}
import java.text.DecimalFormat;
public class Coins
{
public final DecimalFormat MONEY = new DecimalFormat( "$#,##0.00" );
public Coins( int newQuarters, int newDimes, int newNickels, int newPennies )
{
setQuarters( newQuarters );
setDimes( newDimes );
setNickels( newNickels );
setPennies( newPennies );
}
/** getQuarters method
* @return number of dimes
*/
public int getQuarters( )
{
if (Quarters == 0)
{
System.out.print ("You have no quarters.\n" );
}
else
{
return Quarters;
}
}
}
************************************************** ************************************************** *************************
C:\Users\Randy\Documents\Trine University\CS113 Java Programming\Chapter7Prog1RandyHaupert.java:26: error: class, interface, or enum expected
import java.text.DecimalFormat;
^
1 error
Tool completed with exit code 1
************************************************** ************************************************** *************************