Question: trying to convert a entered number into quarters, nickels, dimes, and pennies. Having a few problems: 

```
    public class Coins {
public static void main(String[] args){

private int quarters, dimes, nickels, pennies;

public void CoinsToChange(TotalCoins){
    quarters = (int)(TotalCoins/25);
    TotalCoins %= 25;
    dimes = (int)(TotalCoins/10);
    TotalCoins %= 10;
    nickels = (int)(TotalCoins/5);
    TotalCoins %= 5;
    pennies = (int)(TotalCoins/1);
    TotalCoins %= 1;

    System.out.println("Quarters = " + quarters + "\nDimes = " + dimes + "\nNickels = " + nickels + "\nPennies = " + pennies);
    }
}
    }

```

and this is my tester class: (im having problems calling the CoinsTotChange method.)

```
     import java.util.Scanner;

    public class CoinsTester {
    Coins money = new Coins();
    money.CoinsToChange(changeMoney);
    Scanner kybd = new Scanner(System.in);
    int changeMoney = kybd.nextInt();

```

}

Answer: 
**These are the problems:**

* In your Coins class, you have attempted to wrap everything inside the main method. You need to declare your method and variables separately, and then call them in the main method.
* Instead of making a main method in your Coins class, it should be in your tester class.
* When you declare a method with parameters, you need to specify the type. So instead of `public void CoinsToChange(TotalCoins)` it should be `public void CoinsToChange(int TotalCoins)`.
* Finally, in your tester class, you were calling `money.CoinsToChange(changeMoney)` before you declared and assigned `changeMoney` in `int changeMoney = kybd.nextInt()`. You need to put that line after it instead of before it.

Making as few changes as possible, I got your code to work like so:

```
public class Coins {

    private int quarters, dimes, nickels, pennies;

    public void CoinsToChange(int TotalCoins) {
        quarters = (int) (TotalCoins / 25);
        TotalCoins %= 25;
        dimes = (int) (TotalCoins / 10);
        TotalCoins %= 10;
        nickels = (int) (TotalCoins / 5);
        TotalCoins %= 5;
        pennies = (int) (TotalCoins / 1);
        TotalCoins %= 1;

        System.out.println("Quarters = " + quarters + "\nDimes = " + dimes
                + "\nNickels = " + nickels + "\nPennies = " + pennies);
    }
}

```

Tester class:

```
 import java.util.Scanner;

    public class CoinsTester {

        public static void main(String[] args) {
            Coins money = new Coins();
            Scanner kybd = new Scanner(System.in);
            int changeMoney = kybd.nextInt();
            money.CoinsToChange(changeMoney); // This line needs to be at the bottom
        }
    }

```

***NOTE:** Some of the other answers also give you good suggestions having to do with better variable names and use of String formatting. It would be good to take their advice. I specifically wanted to address the compiler errors.*
As far as I see there is whole bunch of problems with provided code. 

In your first code sample you introduce function declaration and private fields within 

> 
> public static void main(String[] args){ }
> 
> 
> 

, so your class will not compile and hence you'll be unable to use it from some other class 

Then, you are using variable before declaring it as @Tank suggested in his answer. 

It's also considered to be a good practice to stick with generally accepted naming conventions and formatting.