Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-26-2008, 11:08 PM
Member
 
Join Date: Jul 2008
Posts: 43
ljk8950 is on a distinguished road
Java Inventory Program Part 3
Hello everyone,

This is my first post to this forum and I am hoping someone out there can help me. I am an online student and the teachers are never available to help students on the weekend. I have been working steadily on an assignment form my Java class for the past 5 days. This assignment is due tomorrow 7/28/08. Below is the requirements of the assignment:

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.

My problem is that the new feature and restocking fee do not display when the program compiles. Can anyone please help me figure this out? Thanks in advance!

Here is my program:

// 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

supplies notepads = new supplies( 4000, "notepads", 60, 2.75, "Ampad" );
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( "Number of Units: "+suppliesUnits );
System.out.printf( "Unit Price: $%.2f", suppliesPrice );

// 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()

} // end class manufacturer
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-26-2008, 11:52 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SW MO, USA
Posts: 1,481
Norm is on a distinguished road
Quote:
My problem is that the new feature and restocking fee do not display when the program compiles.
Do you mean when the program executes?
Are there any errors in the compile?
What is output when the program executes?
If nothing is being displayed, add println() statements to various methods until you see the output from them. Then copy that here with your questions and comments.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-27-2008, 02:18 AM
Member
 
Join Date: Jul 2008
Posts: 43
ljk8950 is on a distinguished road
Reply to Norm
Norm,

Below is what displays when the program executes.

Welcome to Inventory Program Part 3!

Product Number: 1000
Product Name: envelopes
Number of Units: 15
Unit Price: $5.25
Inventory value of envelopes is = $78.75

Product Number: 2000
Product Name: folders
Number of Units: 30
Unit Price: $4.75
Inventory value of folders is = $142.50

Product Number: 3000
Product Name: markers
Number of Units: 45
Unit Price: $3.50
Inventory value of markers is = $157.50

Product Number: 4000
Product Name: notepads
Number of Units: 60
Unit Price: $2.75
Inventory value of notepads is = $165.00

Product Number: 5000
Product Name: pencils
Number of Units: 75
Unit Price: $1.25
Inventory value of pencils is = $93.75

Total inventory value is: $637.50

Thank you for using Inventory Program Part 3!


I am not gettting any error messages. However, the new feature, which is "manufacturer", and the restocking fee do not display. Any ideas of what I can do to fix this?
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-27-2008, 04:08 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: SW MO, USA
Posts: 1,481
Norm is on a distinguished road
Where are the new features supposed to display?
Where in your program is the code to println() them?
toString() appears to build a String with the values, but where is that String printed?
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-27-2008, 04:47 AM
Member
 
Join Date: Jul 2008
Posts: 43
ljk8950 is on a distinguished road
Reply to Norm
Norm,

I am sorry I have done so many revisions to this program, I posted the wrong version. Below is the current version. At the end of the subclass I have the println() for the program. I really appreciate your help. Please let me know what you think I am doing wrong. Thanks!

// 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

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( "Number of Units: "+suppliesUnits );
System.out.printf( "Unit Price: $%.2f", suppliesPrice );

// 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( "Manufacturer: "+suppliesManufacturer );

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

} // end method display inventory

} // end class manufacturer
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 07-27-2008, 05:02 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Hi ljk8950, please use the code tags when you posting your codes next time here in the forum. It's really helpful to read your code for others and replying to you. I think you know hoe to do it.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 07-27-2008, 05:05 AM
Member
 
Join Date: Jul 2008
Posts: 43
ljk8950 is on a distinguished road
Reply to Eranga
Eranga,

Today is the first day I have ever posted to this forum. What are the code tags and how do I use them?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 07-27-2008, 06:00 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
On the message replay are you can see some text editing tools, like bold, italic, copy, paste, etc... On that menu area you can find the [code] tags. Just keep your cursor on top of those icons for a while. Tool tip explain what it means. After find the [code] tags, just lick on it and see what happened.

You have a pair of code tags, one for opening and the other for closing. In between those two paste your code. Then it look like this.

Code:
Your code goes here.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 07-27-2008, 06:12 AM
Member
 
Join Date: Jul 2008
Posts: 43
ljk8950 is on a distinguished road
Reply to Eranga
Eranga,

Thanks for the info. I am going to post my code again to see if it displays betters. Please let me know if I did it right. By the way, I am still looking for help with this code. If anyone out there can help me, I would very much appreciate it. Thank you!

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 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( "Number of Units: "+suppliesUnits ); System.out.printf( "Unit Price: $%.2f", suppliesPrice ); // 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( "Manufacturer: "+suppliesManufacturer ); // Display value plus restocking fee System.out.printf( "\nInventory value of "+suppliesName+ " is = $%.2f\n", getRestockingFee() ); } // end method display inventory } // end class manufacturer
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 07-27-2008, 06:17 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yes, now it's better.

Lets go to your question. You want to display manufacture details in showInventory() method, right? But I can't see that you have call the manufacture class instance with the required member you want.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 07-27-2008, 07:21 AM
Member
 
Join Date: Jul 2008
Posts: 43
ljk8950 is on a distinguished road
Reply to Eranga
Eranga,

Can you show me an example of what you mean by call the manufacturer call instance? My brain is fried right now. I have been working on this for 12 hours straight. Thank you for your help!
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 07-27-2008, 07:47 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ok, at the time just forget what I said.

From where you call the showInventory() method in the manufacture class? Did you call it? No, right?

SO how did you call that function?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 07-27-2008, 08:14 AM
Member
 
Join Date: Jul 2008
Posts: 43
ljk8950 is on a distinguished road
Reply to Eranga
Eranga,

Isn't this my call of the manufacturer function?

Code:
// 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
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 07-27-2008, 08:28 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,486
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yes that's right. You have set the values for manufacture and implement the get method there too, it's fine. Now what I'm asking is where you call the getManufacture() method to get values? Is that clear?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 07-27-2008, 08:40 AM
Member
 
Join Date: Jul 2008
Posts: 43
ljk8950 is on a distinguished road
Reply to Eranga
Is this what you are referring to? Currently, I have this located in the supplies class. I don't think this is right. However, I am able to get the word manufacturer to display when the program is executed. Unfortunately, the manufacturer for this single product displays with all products when executed. I think I am close but so tired right now that I am missing something. Do you hava any idea what that might be?

Code:
manufacturer supplies = new manufacturer ( 4000, "notepads", 60, 2.75, "Ampad" ); System.out.println( "\nManufacturer: "+supplies.getManufacturer() );
Bookmark Post in Technorati
Reply With Quote
  #16 (permalink)  
Old 07-27-2008, 08:56 AM
Member
 
Join Date: Jul 2008
Posts: 43
ljk8950 is on a distinguished road
Reply to Everyone
I have been working at this project for hours and have made some changes. Therefore, I have posted the changes I have made and what displays when the program is executed as an update. I am going to go to bed now and hopefully I will have a fresh perspective in the morning. The deadline for this assignment is midnight tomorrow night (7/28/08). Therefore, I need to have this resolved sometime tomorrow. If anyone out there can help me with this, I would be forever grateful. I really want to learn this. I don't feel I can go on to future assignments until I have this mastered. I will be getting up early tomorrow to start on this and will be rechecking any post in this forum that is made late tonight. Again, many thanks to everyone who replies to this post.


Code:
This is my updated 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 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(