Results 1 to 2 of 2
  1. #1
    sabrown311313 is offline Member
    Join Date
    Sep 2008
    Posts
    3
    Rep Power
    0

    Default My Java program will not compile and run?

    Can you please help me compile and run this program. I have been going back trying to figure out what the errors for three days straight.:mad:


    /**
    Inventory Program Part 5
    */
    //import java libraries
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.text.*;
    import java.util.*;

    public class InventoryProgramPart5 extends JFrame implements ActionListener
    {


    softwares[] softwares = new softwares[100]; // an array of 100 supplies


    //maintain current record index
    protected int currentRecord = 0;



    //text field declaration
    protected JFormattedTextField jtfIndex;
    protected JFormattedTextField jtfID;
    protected JFormattedTextField jtfTitle;
    protected JFormattedTextField jtfStock;
    protected JFormattedTextField jtfPrice;
    protected JFormattedTextField jtfInvValue;
    protected JFormattedTextField jtfTotalValue;
    protected JFormattedTextField jtfRating;
    protected JFormattedTextField jtfFee;

    //button declaration

    protected JButton jbtFirst;
    protected JButton jbtPrevious;
    protected JButton jbtNext;
    protected JButton jbtLast;
    protected JButton jbtDVD;

    //set locale and format for currency values
    NumberFormat n = NumberFormat.getCurrencyInstance(Locale....
    DecimalFormat pf = new DecimalFormat("#0.00");

    // set up GUI
    public InventoryProgramPart5()
    {

    super( "Inventory of Software Part 5" );


    //populate the array
    softwares buisness = new softwares( 4000, "Microsoft Office 2007", 60, 120.75 );
    softwares security = new softwares( 5000, "Norton Internet Security 2009", 75, 75.00 );
    softwares games = new softwares( 2000, "World of Warcraft Pc Game", 30, 66.00 );
    softwares os1 = new softwares( 1000, "Windows Vista", 15, 245.25 );
    softwares os2 = new softwares( 3000, "Windows XP", 45, 175.50 );

    // Panel jpLabels to hold labels
    JPanel jpLabels = new JPanel();
    jpLabels.setLayout(new GridLayout(9, 1));
    jpLabels.add(new JLabel(" Index"));
    jpLabels.add(new JLabel(" Item ID"));
    jpLabels.add(new JLabel(" Name"));
    jpLabels.add(new JLabel(" Rating"));
    jpLabels.add(new JLabel(" # in Stock"));
    jpLabels.add(new JLabel(" Price"));
    jpLabels.add(new JLabel(" Restocking Fee (5%)"));
    jpLabels.add(new JLabel(" Inventory Value with fee"));
    jpLabels.add(new JLabel(" Total Value with fee (for all the items) "));

    // Panel jpTextFields to hold text fields
    JPanel jpTextFields = new JPanel();
    jpTextFields.setLayout(new GridLayout(9, 1));
    jpTextFields.add(jtfIndex = new JFormattedTextField());
    jpTextFields.add(jtfID = new JFormattedTextField());
    jpTextFields.add(jtfTitle = new JFormattedTextField());
    jpTextFields.add(jtfRating = new JFormattedTextField());
    jpTextFields.add(jtfStock = new JFormattedTextField());
    jpTextFields.add(jtfPrice = new JFormattedTextField());
    jpTextFields.add(jtfFee = new JFormattedTextField());
    jpTextFields.add(jtfInvValue = new JFormattedTextField());
    jpTextFields.add(jtfTotalValue = new JFormattedTextField());

    // Panel p1 for holding jpLables and jpTextFields
    JPanel p1 = new JPanel();
    p1.setLayout(new BorderLayout());
    p1.add(jpLabels, BorderLayout.WEST);
    p1.add(jpTextFields, BorderLayout.CENTER);



    // Panel p3 for data navigation
    JPanel p3 = new JPanel();
    p3.setLayout(new FlowLayout());
    p3.add(jbtDVD = new JButton(new ImageIcon("logo.jpg")));

    p3.add(jbtFirst = new JButton("First"));
    p3.add(jbtPrevious = new JButton("Previous"));
    p3.add(jbtNext = new JButton("Next"));
    p3.add(jbtLast = new JButton("Last"));

    // Place panels into the frame
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(p1, BorderLayout.CENTER);
    getContentPane().add(p3, BorderLayout.SOUTH);

    // Register listeners with the buttons
    jbtFirst.addActionListener(this);
    jbtPrevious.addActionListener(this);
    jbtNext.addActionListener(this);
    jbtLast.addActionListener(this);
    loadInventory();

    }



    // display inventory
    public void showInventory()
    {
    System.out.println(); // outputs blank line

    System.out.println( "Product Number: "+softwareNumber );
    System.out.println( "Product Name: "+softwareName );
    System.out.println( "Number of Units: "+softwareUnits );
    System.out.printf( "Unit Price: $%.2f",+softwarePrice );

    // value() method and display the value
    System.out.printf( "\nInventory value of "+softwareName+ " is = $%.2f\n",
    getValue() );

    } // end display inventory

    } // end class softwares

    class manufacturer extends softwares
    {
    // holds the softwares manufacturer
    private String softwaresManufacturer;

    // five-argument constructor
    manufacturer( int number, String name, int units,
    double price, String manufacturer )
    {
    super( number, name, units, price );
    softwaresManufacturer = manufacturer;
    } // end five-argument constructor

    // set supplies manufacturer
    public void setManufacturer( String manufacturer )
    {
    this.softwaresManufacturer = manufacturer;
    } // end method set softwares manufacturer

    // return softwares manufacturer
    public String getManufacturer()
    {
    return softwaresManufacturer;
    } // end method get softwares manufacturer

    // add 5% restocking fee
    public double getValue()
    {
    return super.getValue() * 1.05;
    } // end method return softwares manufacturer

    // calculate restocking fee
    public double getRestockingFee()
    {
    return super.getValue() * .05;
    } //end method calculate restocking fee

    //return String representation of suppliesManufacturer
    public String toString()
    {
    String formatString = "Manufacturer: %s";
    formatString += "Restocking Fee: $%.2f";
    formatString = String.format( formatString, softwaresManufacturer,
    super.getValue() * 0.05 );
    return( formatString + super.toString() );
    } // end toString()

    // display inventory
    public void showInventory()
    {
    super.showInventory();
    System.out.println( toString() );
    System.out.println( "Manufacturer: "+softwaresManufacturer );

    // Display value plus restocking fee
    System.out.printf( "\nInventory value of "+softwareName+ " is = $%.2f\n",
    getRestockingFee() );

    } // end method display inventory

    } // end class manufacturer

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

Similar Threads

  1. Program Won't Compile
    By JavaLovenJoe in forum New To Java
    Replies: 2
    Last Post: 04-22-2008, 02:31 PM
  2. Replies: 0
    Last Post: 02-17-2008, 09:57 AM
  3. Replies: 2
    Last Post: 08-06-2007, 10:16 PM
  4. Help with Java Compile File
    By baltimore in forum New To Java
    Replies: 1
    Last Post: 08-06-2007, 08:48 AM
  5. Compile a program
    By toby in forum New To Java
    Replies: 2
    Last Post: 07-30-2007, 10:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •