Results 1 to 8 of 8
  1. #1
    ljk8950 is offline Member
    Join Date
    Jul 2008
    Posts
    43
    Rep Power
    0

    Default Inventory Program Part 3 - DUE TODAY (7/28/08)

    PLEASE HELP!!!!

    I know we are not suppose to post more than one on the same issue. However, I am panicking over this assignment which is due today. I have been working on it for 5 days straight. I need someone to point me in the right direction of how to get the manufacturer sublclass to display a manufacturer for each supply and how to get the restocking fee to display. I can get the program to compile but these items are not displayed correctly. The manufacturer feature seems to display the same manufacturer for all the supplies. I have only entered one thus far. However, when I enter multiple manufacturers I get error codes. Below is my most current version of the program and below it is what compiles. Thanks to anyone who can help me before I have a complete melt down over this project. I have placed several calls and emails to my teacher in the last several days and he has not responded. Therefore, I will be eternally grateful to anyone who can help me.:confused:

    Java Code:
    // CheckPoint:  InventoryProgramPart3.java
    // Week 6
    // This program calculates inventory value
    
    import java.util.Scanner;
    import java.util.Arrays;
    
    public class InventoryProgramPart3
    {
    
         // main method begins program execution
         public static void main(String args[] )
         {
              // create Scanner to obtain input from command window
              Scanner input = new Scanner( System.in );
    
              // display a welcome message to the InventoryProgramPart3 user
              System.out.println( "Welcome to Inventory Program Part 3!" );
    
              // office supplies
              
              supplies[] supplies = new supplies[100]; // an array of 100 supplies
              manufacturer[] manufacturer = new manufacturer[100];
                    
              supplies notepads = new supplies( 4000, "notepads", 60, 2.75 );
              supplies pencils = new supplies( 5000, "pencils", 75, 1.25 );
              supplies folders = new supplies( 2000, "folders", 30, 4.75 );
              supplies envelopes = new supplies( 1000, "envelopes", 15, 5.25 );
              supplies markers = new supplies( 3000, "markers", 45, 3.50 );
                                 
              // display the inventories one at a time
              envelopes.showInventory();
              folders.showInventory();
              markers.showInventory();
              notepads.showInventory();
              pencils.showInventory();
    
              // sort supplies by name
              for ( int i = 0; i < args.length; i++ )
              System.out.println( args[i] + ", " );
    
              double array[] = { 78.75, 142.50, 157.50, 165.00, 93.75 };
              double total = 0;
    
              // add each element's value to total
              for ( int counter = 0; counter < array.length; counter++)
                   total += array[ counter ];
              System.out.printf( "\nTotal inventory value is: $%.2f\n", total );
    
              System.out.println( "\nThank you for using Inventory Program Part 3!\n" );
              
         } // end method main
    
    } // end class InventoryProgramPart3     
    
    // Office Supplies
    class supplies
    {
         public int suppliesNumber;
         public String suppliesName = new String();
         public int suppliesUnits;
         public double suppliesPrice;
    
         // set supplies number
         public void setSuppliesNumber( int number )
         {
              this.suppliesNumber = number;
         } // end method set supplies number
    
         // return supplies number
         public int getSuppliesNumber()
         {
              return suppliesNumber;
         } // end method get supplies number
    
         // set supplies name
         public void setSuppliesName( String name )
         {
              this.suppliesName = name;
         } // end method set supplies name
    
         // return supplies name
         public String getSuppliesName()
         {
              return suppliesName;
         } // end method get supplies name
    
         // set supplies in stock
         public void setSuppliesUnits( int units )
         {
              this.suppliesUnits = units;
         } // end method set supplies units
    
         // return supplies units
         public int getSuppliesUnits()
         {
              return suppliesUnits;
         } // end method get supplies units
    
         // set supplies price
         public void setSuppliesPrice( double price )
         {
              this.suppliesPrice = price;
         } // end method set supplies price
    
         // return supplies price
         public double getSuppliesPrice()
         { 
              return suppliesPrice;
         } // end method get supplies price
    
         // calculate supplies inventory value
         public double getValue()
         {
              return suppliesUnits * suppliesPrice;
         } // end method supplies inventory value 
    
        // four-argument constructor
         supplies( int number, String name, int units, double price )
         { 
              suppliesNumber = number;
              suppliesName = name;
              suppliesUnits = units;
              suppliesPrice = price;
         } // end four-argument constructor
    
        // display inventory
         public void showInventory()
         {
              System.out.println(); // outputs blank line
    
              System.out.println( "Product Number:  "+suppliesNumber );
              System.out.println( "Product Name:  "+suppliesName );
              System.out.println( "Units in Stock:  "+suppliesUnits );
              System.out.printf( "Unit Price:  $%.2f", suppliesPrice );
    
              manufacturer supplies = new manufacturer
                   ( 4000, "notepads", 60, 2.75, "Ampad" );    
              
              System.out.println( "\nManufacturer:  "+supplies.getManufacturer() );  
                        
              // value() method and display the value
              System.out.printf( "\nInventory value of "+suppliesName+ " is = $%.2f\n",
                   getValue() );     
      
        } // end display inventory
    
    } // end class supplies
    
    class manufacturer extends supplies
    {
         // holds the supplies manufacturer
         private String suppliesManufacturer;
    
         // five-argument constructor
         manufacturer( int number, String name, int units,
              double price, String manufacturer )
         {
              super( number, name, units, price );
              suppliesManufacturer = manufacturer;
         } // end five-argument constructor
    
         // set supplies manufacturer
         public void setManufacturer( String manufacturer )
         {
              this.suppliesManufacturer = manufacturer;
         } // end method set supplies manufacturer
    
         // return supplies manufacturer
         public String getManufacturer()
         {
             return suppliesManufacturer;
         } // end method get supplies manufacturer
    
         // add 5% restocking fee
         public double getValue()
         {
              return super.getValue() * 1.05;
         } // end method return supplies 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, suppliesManufacturer,
                   super.getValue() * 0.05 );
              return( formatString + super.toString() );
         } // end toString()
    
         // display inventory
         public void showInventory()
         {
              super.showInventory();
              System.out.println( toString() );
              System.out.println( "\nManufacturer:  "+getManufacturer() );
    
              // Display value plus restocking fee
              System.out.printf( "\nInventory value of "+suppliesName+ " is = $%.2f\n",
                   getRestockingFee() );     
    
         } // end method display inventory
    
    } // end class manufacturer
    Below is what displays when the program executes:

    Java Code:
    Welcome to Inventory Program Part 3!
    
    Product Number:  1000
    Product Name:  envelopes
    Units in Stock:  15
    Unit Price:  $5.25
    Manufacturer:  Ampad
    
    Inventory value of envelopes is = $78.75
    
    Product Number:  2000
    Product Name:  folders
    Units in Stock:  30
    Unit Price:  $4.75
    Manufacturer:  Ampad
    
    Inventory value of folders is = $142.50
    
    Product Number:  3000
    Product Name:  markers
    Units in Stock:  45
    Unit Price:  $3.50
    Manufacturer:  Ampad
    
    Inventory value of markers is = $157.50
    
    Product Number:  4000
    Product Name:  notepads
    Units in Stock:  60
    Unit Price:  $2.75
    Manufacturer:  Ampad
    
    Inventory value of notepads is = $165.00
    
    Product Number:  5000
    Product Name:  pencils
    Units in Stock:  75
    Unit Price:  $1.25
    Manufacturer:  Ampad
    
    Inventory value of pencils is = $93.75
    
    Total inventory value is: $637.50
    
    Thank you for using Inventory Program Part 3!

  2. #2
    ljk8950 is offline Member
    Join Date
    Jul 2008
    Posts
    43
    Rep Power
    0

    Default By the Way

    Below is the exact instructions for the assignment:

    Due Date: Sunday, July 28, 2008 at midnight

    Modify the Inventory Program by creating a subclass of the product class that uses one additional unique feature of the product you chose (for the DVDs subclass, you could use movie title, for example). In the subclass, create a method to calculate the value of the inventory of a product with the same name as the method previously created for the product class. The subclass method should also add a 5% restocking fee to the value of
    the inventory of that product.

    Modify the output to display this additional feature you have chosen and the restocking fee.

  3. #3
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,339
    Rep Power
    25

    Default

    formatString =
    Take a look at your code and be sure you are concatenating to the current value vs assigning a new value

  4. #4
    ljk8950 is offline Member
    Join Date
    Jul 2008
    Posts
    43
    Rep Power
    0

    Default Reply to Norm

    Norm,

    Below is my updated code. I did noticed I had a couple things referred to as manufacturer vs. suppliesManufacturer. I changed those. However, the outcome is still the same. If I am not calling a method right, I just don't see it. Do you see anything in my code that I should look at in particular? Any feedback would be appreciated. Thank you!


    Java Code:
    // CheckPoint:  InventoryProgramPart3.java
    // Week 6
    // This program calculates inventory value
    
    import java.util.Scanner;
    import java.util.Arrays;
    
    public class InventoryProgramPart3
    {
    
         // main method begins program execution
         public static void main(String args[] )
         {
              // create Scanner to obtain input from command window
              Scanner input = new Scanner( System.in );
    
              // display a welcome message to the InventoryProgramPart3 user
              System.out.println( "Welcome to Inventory Program Part 3!" );
    
              // office supplies
              
              supplies[] supplies = new supplies[100]; // an array of 100 supplies
              manufacturer[] manufacturer = new manufacturer[100];
                    
              supplies notepads = new supplies( 4000, "notepads", 60, 2.75 );
              supplies pencils = new supplies( 5000, "pencils", 75, 1.25 );
              supplies folders = new supplies( 2000, "folders", 30, 4.75 );
              supplies envelopes = new supplies( 1000, "envelopes", 15, 5.25 );
              supplies markers = new supplies( 3000, "markers", 45, 3.50 );
                                 
              // display the inventories one at a time
              envelopes.showInventory();
              folders.showInventory();
              markers.showInventory();
              notepads.showInventory();
              pencils.showInventory();
    
              // sort supplies by name
              for ( int i = 0; i < args.length; i++ )
              System.out.println( args[i] + ", " );
    
              double array[] = { 78.75, 142.50, 157.50, 165.00, 93.75 };
              double total = 0;
    
              // add each element's value to total
              for ( int counter = 0; counter < array.length; counter++)
                   total += array[ counter ];
              System.out.printf( "\nTotal inventory value is: $%.2f\n", total );
    
              System.out.println( "\nThank you for using Inventory Program Part 3!\n" );
              
         } // end method main
    
    } // end class InventoryProgramPart3     
    
    // Office Supplies
    class supplies
    {
         public int suppliesNumber;
         public String suppliesName = new String();
         public int suppliesUnits;
         public double suppliesPrice;
    
         // set supplies number
         public void setSuppliesNumber( int number )
         {
              this.suppliesNumber = number;
         } // end method set supplies number
    
         // return supplies number
         public int getSuppliesNumber()
         {
              return suppliesNumber;
         } // end method get supplies number
    
         // set supplies name
         public void setSuppliesName( String name )
         {
              this.suppliesName = name;
         } // end method set supplies name
    
         // return supplies name
         public String getSuppliesName()
         {
              return suppliesName;
         } // end method get supplies name
    
         // set supplies in stock
         public void setSuppliesUnits( int units )
         {
              this.suppliesUnits = units;
         } // end method set supplies units
    
         // return supplies units
         public int getSuppliesUnits()
         {
              return suppliesUnits;
         } // end method get supplies units
    
         // set supplies price
         public void setSuppliesPrice( double price )
         {
              this.suppliesPrice = price;
         } // end method set supplies price
    
         // return supplies price
         public double getSuppliesPrice()
         { 
              return suppliesPrice;
         } // end method get supplies price
    
         // calculate supplies inventory value
         public double getValue()
         {
              return suppliesUnits * suppliesPrice;
         } // end method supplies inventory value 
    
        // four-argument constructor
         supplies( int number, String name, int units, double price )
         { 
              suppliesNumber = number;
              suppliesName = name;
              suppliesUnits = units;
              suppliesPrice = price;
         } // end four-argument constructor
    
        // display inventory
         public void showInventory()
         {
              System.out.println(); // outputs blank line
    
              System.out.println( "Product Number:  "+suppliesNumber );
              System.out.println( "Product Name:  "+suppliesName );
              System.out.println( "Units in Stock:  "+suppliesUnits );
              System.out.printf( "Unit Price:  $%.2f", suppliesPrice );
    
              manufacturer supplies = new manufacturer
                   ( 4000, "notepads", 60, 2.75, "Ampad" );    
              
              System.out.println( "\nManufacturer:  "+supplies.getSuppliesManufacturer() );  
                        
              // value() method and display the value
              System.out.printf( "\nInventory value of "+suppliesName+ " is = $%.2f\n",
                   getValue() );     
      
        } // end display inventory
    
    } // end class supplies
    
    class manufacturer extends supplies
    {
         // holds the supplies manufacturer
         private String suppliesManufacturer;
    
         // five-argument constructor
         manufacturer( int number, String name, int units,
              double price, String manufacturer )
         {
              super( number, name, units, price );
              suppliesManufacturer = manufacturer;
         } // end five-argument constructor
    
         // set supplies manufacturer
         public void setSuppliesManufacturer( String manufacturer )
         {
              this.suppliesManufacturer = manufacturer;
         } // end method set supplies manufacturer
    
         // return supplies manufacturer
         public String getSuppliesManufacturer()
         {
             return suppliesManufacturer;
         } // end method get supplies manufacturer
    
         // add 5% restocking fee
         public double getValue()
         {
              return super.getValue() * 1.05;
         } // end method return supplies 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, suppliesManufacturer,
                   super.getValue() * 0.05 );
              return( formatString + super.toString() );
         } // end toString()
    
         // display inventory
         public void showInventory()
         {
              super.showInventory();
              System.out.println( toString() );
              System.out.println( "\nManufacturer:  "+getSuppliesManufacturer() );
    
              // Display value plus restocking fee
              System.out.printf( "\nInventory value of "+suppliesName+ " is = $%.2f\n",
                   getRestockingFee() );     
    
         } // end method display inventory
    
    } // end class manufacturer

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,339
    Rep Power
    25

    Default

    Try some debugging!
    Add some println() statements to your code where you think there is a problem with values of variables and see what's happening.
    Last edited by Norm; 07-27-2008 at 08:18 PM.

  6. #6
    ljk8950 is offline Member
    Join Date
    Jul 2008
    Posts
    43
    Rep Power
    0

    Default Reply to Norm

    I have done that already. I keep getting the "cannot find symbol error" message. So I delete the println and try something else. The cannot find symbol error message does not tell me where the error is or how to correct it. I think I have spent the last 48 hours making changes and deleting the changes when they do not work. I figured if my program at least compiles I am better off than when it doesn't compile. This assignment only required we had a subclass and display additional output. Do I need to add anything to my supplies class or main to get this to happen? Or, is my error only simply in my subclass somewhere? Thanks for any help you can give me.

  7. #7
    ljk8950 is offline Member
    Join Date
    Jul 2008
    Posts
    43
    Rep Power
    0

    Default Reply to Norm

    Norm,

    Below are two sections of my code that I am not sure if it is right. Maybe this is where my problem is. Can you please take a look and let me know what you think? Thank you!

    Java Code:
     // set supplies manufacturer
         public void setSuppliesManufacturer( String manufacturer )
         {
              this.suppliesManufacturer = manufacturer;
         } // end method set supplies manufacturer
    Java Code:
        //return String representation of suppliesManufacturer
         public String toString()
         {
              String formatString = "Manufacturer:  %s";
              formatString += "Restocking Fee:  $%.2f";
              formatString = String.format( formatString, suppliesManufacturer,
                   super.getValue() * 0.05 );
              return( formatString + super.toString() );
         } // end toString()
    
         // display inventory
         public void showInventory()
         {
              super.showInventory();
              System.out.println( toString() );
              System.out.println( "\nManufacturer:  "+getSuppliesManufacturer() );
    
              // Display value plus restocking fee
              System.out.printf( "\nInventory value of "+suppliesName+ " is = $%.2f\n",
                   getRestockingFee() );     
    
         } // end method display inventory

  8. #8
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,339
    Rep Power
    25

    Default

    I keep getting the "cannot find symbol error" message.
    You need to post the compiler output when you get errors you don't understand. You are either misspelling something or don't have the correct path set (done with import ...) for the compiler to find the definition for the symbol. Don't ignore it! YOU need to know how to debug your program. System.out.println() is one of the tools to use.
    The code you show looks like it would print something. There appears to be three print statements. What's missing and from what print statement?

    Why do you call super.toString()?
    Have you read the API doc for the toString() method? What does it return? Do you have any interest in that?

Similar Threads

  1. Java Inventory Program Part 3
    By ljk8950 in forum New To Java
    Replies: 18
    Last Post: 07-28-2008, 05:47 AM
  2. Inventory Program modification help
    By badness in forum Java Applets
    Replies: 1
    Last Post: 01-17-2008, 05:24 AM
  3. Inventory part 3 program problems
    By badness in forum New To Java
    Replies: 1
    Last Post: 12-17-2007, 07:00 AM
  4. Inventory part 2 help please
    By badness in forum New To Java
    Replies: 1
    Last Post: 12-12-2007, 07:51 AM
  5. Inventory program
    By Nexcompac in forum New To Java
    Replies: 3
    Last Post: 07-27-2007, 05:51 PM

Posting Permissions

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