Hi everyone! Looking for some help for my java homework if possible. I am writing code for a miles per gallon calculator. I am finished with the program and it works but there are some specifics in the assignment that I am unsure how to implement into my own code. Here are the directions I am stuck on-

Create a class named RunMPGGui.java that will instantiate a MPGGui object. In addition to creating the MPGGui object, the class should do the following:

1 Set the window width to 225 and its height to 200.
2 Set the window to display in the center of the screen.
3 Make the window visible.
Now in my own code all of these are in the MPGGui object that RunMPGGui.java is using. However the assignment calls for these to be in the RunMPGGui java file. If I use the same code and just put it into RunMPGGui it errors when compiled with several errors. Here is my code when it works
Java Code:
import javax.swing.*;
import java.awt.event.*;
import java.text.DecimalFormat;

public class MPGgui extends JFrame
{
   private JPanel panel;
   private JLabel mpgCalc;
   private JLabel milesTrav;
   private JLabel galUsed;
   private JTextField mileTextField;
   private JTextField galTextField;
   private JButton calcButton;
   private JButton quitButton;
   private final int WINDOW_WIDTH = 225;
   private final int WINDOW_HEIGHT = 200;

   public MPGgui()
   {

      setTitle("MPG Calculator");

      setSize(WINDOW_WIDTH, WINDOW_HEIGHT);

      setLocationRelativeTo(null);

      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      buildPanel();

      add(panel);

      setVisible(true);
   }

   private void buildPanel()
   {
      mpgCalc = new JLabel("MPG Calculator");

      milesTrav = new JLabel("Enter miles travelled");

      galUsed = new JLabel("Enter gallons used    ");

      mileTextField = new JTextField(6);

      galTextField = new JTextField(6);

      calcButton = new JButton("Calculate MPG");

      calcButton.addActionListener(new CalcButtonListener());

      quitButton = new JButton("Quit");

      quitButton.addActionListener(new QuitButtonListener());

      panel = new JPanel();

      panel.add(mpgCalc);

      panel.add(milesTrav);

      panel.add(mileTextField);

      panel.add(galUsed);

      panel.add(galTextField);

      panel.add(calcButton);

      panel.add(quitButton);
   }

   private class CalcButtonListener implements ActionListener
   {

      public void actionPerformed(ActionEvent e)
      {

	 double miles;
	 double gallons;
	 double mpg;

         miles = Double.parseDouble(mileTextField.getText());

         gallons = Double.parseDouble(galTextField.getText());

         mpg = miles/gallons;

         DecimalFormat formatter = new DecimalFormat("#0.00");

         JOptionPane.showMessageDialog(null, "Distance: " + formatter.format(miles) +
                                       "\n Miles per Gallon: " + formatter.format(mpg));
      }
   }

   private class QuitButtonListener implements ActionListener
   {

      public void actionPerformed(ActionEvent e)
      {

      System.exit(0);

      }
   }

}
and this one

Java Code:
public class RunMPGGui
{

   public static void main(String[] args)
   {

      MPGgui mg = new MPGgui();

   }
}
Any help?