Here's the formulation of the linear program and the Gurobi code to solve it:

**Decision Variables:**

* `x`: Number of mini bears made.
* `y`: Number of mini dogs made.

**Objective Function:**

Maximize profit: `40x + 47y`

**Constraints:**

* **Cotton Constraint:** `8x + 7y <= 400` (Total cotton used cannot exceed available cotton)
* **Production Capacity Constraint:** `x + y <= 40` (Total number of animals cannot exceed the production capacity)
* **Non-negativity Constraints:** `x >= 0`, `y >= 0` (Cannot make a negative number of bears or dogs)


```python
import gurobipy as gp
from gurobipy import GRB

# Create a new model
m = gp.Model("Miniature_Animals")

# Create variables
x = m.addVar(vtype=GRB.INTEGER, name="Mini_Bears")  # Number of mini bears
y = m.addVar(vtype=GRB.INTEGER, name="Mini_Dogs")  # Number of mini dogs

# Set objective function
m.setObjective(40*x + 47*y, GRB.MAXIMIZE)

# Add constraints
m.addConstr(8*x + 7*y <= 400, "Cotton_Constraint")
m.addConstr(x + y <= 40, "Production_Constraint")

# Optimize model
m.optimize()

# Print results
if m.status == GRB.OPTIMAL:
    print(f"Optimal Solution Found:")
    print(f"Number of Mini Bears: {x.x}")
    print(f"Number of Mini Dogs: {y.x}")
    print(f"Maximum Profit: ${m.objVal}")
elif m.status == GRB.INFEASIBLE:
    print("The model is infeasible.")
else:
    print(f"Optimization terminated with status {m.status}")

```
