How do I go about coding this program in Java?

Write a class called PocketChange that models a handful of change you
might find in your pocket. The class has the following specifications:
Instance Variables - all instance variables are private!
o int toonies - the number of toonies in the user's pocket
o int loonies - the number of loonies in the user's pocket
o int quarters - the number of quarters in the user's pocket
o int dimes - the number of dimes in the user's pocket
o int nickels - the number of nickels in the user's pocket
o int pennies - the number of pennies in the user's pocket
Methods:
o PocketChange() - default constructor assigns 0 as a default value
to all instance variables.
o PocketChange(toonies, loonies, quarters, dimes, nickels,
pennies) - sets the values of all the instance variables to the
programmer-specified parameter values.
o Accessor and mutator methods for each instance variable - all
coin values must be 0 or positive values. Exceptions should be
thrown if an attempt is made to set an instance variable to a
negative value.
o calcAmount() - This method calculates and returns the total
amount of money in the user's pocket, based on the values in
each of the instance variables.
o toString() - returns a String with the following format:
o Toonies: t
o Loonies: L
o Quarters: q
o Dimes: d
o Nickels: n
Pennies: p
where t, L, q, d, n, and p are the number of toonies, loonies, quarters,
dimes, nickels and pennies.

To code the PocketChange class in Java, follow these steps:

1. Start by creating a new Java file named PocketChange.java.

2. In the PocketChange class, declare the private instance variables: toonies, loonies, quarters, dimes, nickels, and pennies. Make sure to declare them as int types.

```
public class PocketChange {
private int toonies;
private int loonies;
private int quarters;
private int dimes;
private int nickels;
private int pennies;
}
```

3. Next, create the default constructor PocketChange(). Inside the constructor, assign 0 as the default value to all the instance variables.

```
public PocketChange() {
toonies = 0;
loonies = 0;
quarters = 0;
dimes = 0;
nickels = 0;
pennies = 0;
}
```

4. Implement the parameterized constructor PocketChange(int toonies, int loonies, int quarters, int dimes, int nickels, int pennies). Inside the constructor, set the values of all the instance variables to the provided parameter values.

```
public PocketChange(int toonies, int loonies, int quarters, int dimes, int nickels, int pennies) {
this.toonies = toonies;
this.loonies = loonies;
this.quarters = quarters;
this.dimes = dimes;
this.nickels = nickels;
this.pennies = pennies;
}
```

5. Next, create accessor and mutator methods for each instance variable. These methods allow getting and setting the values of the instance variables, while also ensuring that the coin values are 0 or positive. If an attempt is made to set a negative value, throw an exception.

```
// Example accessor and mutator methods:
public int getToonies() {
return toonies;
}

public void setToonies(int toonies) {
if (toonies >= 0) {
this.toonies = toonies;
} else {
throw new IllegalArgumentException("Toonies cannot be a negative value.");
}
}

// Implement the rest of the accessor and mutator methods similar to the above example.
```

6. Implement the calcAmount() method. This method calculates and returns the total amount of money in the user's pocket, based on the values in each of the instance variables.

```
public int calcAmount() {
int totalAmount = (toonies * 200) + (loonies * 100) + (quarters * 25) + (dimes * 10) + (nickels * 5) + pennies;
return totalAmount;
}
```

7. Implement the toString() method. This method returns a String with the specified format.

```
@Override
public String toString() {
return "Toonies: " + toonies +
"\nLoonies: " + loonies +
"\nQuarters: " + quarters +
"\nDimes: " + dimes +
"\nNickels: " + nickels +
"\nPennies: " + pennies;
}
```

That's it! Your PocketChange class is now coded in Java according to the given specifications. You can add any additional methods or functionality as needed. Remember to save the file and it is ready to be compiled and used in your Java program.