• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1176
  • Last Modified:

Need help creating a basic inventory program in Java

I want to create an inventory of office supplies. The product class needs to hold the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory (the number of units in stock is multiplied by the price of each unit). I am fairly new to the concept of arrays and I was wondering if anyone could help jumpstart it. The type of office supplies that I want to include are; paper, pens, pencils, erasers, and scissors.

  • 2
2 Solutions
seems like an assgnment..

nobody at experts exchange will do the complete assignment for you. but here we will help you in completing it. post what you have done so far. we will guide you from there.

as for as arrays are concerned have a look at this url for a better understanding
pogibear77Author Commented:
You're right, it is for an assignment. Sorry I wasn't able to paste what I've been working on. It takes me almost the whole entire day (including my work time) to try to even understand programming. But this is what I have so far for the inventory portion.

What do I need to do next to display the product number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory. I am guessing that I will need to write a Java application like a test program? I'm confused at this point.
// this is the class for the laptop inventory
import java.util.Arrays
public class Inventorylaptop
	// initializing arrays
	private int laptopNums[];
	private String laptopNames[];
	private int laptopUnits[];
	private double laptopValue[];
	private double inventoryValue[];
	// initializing instance variable
	private double runValue = 0;
	private double totalvalue = 0;
	private int count;
	public Inventorylaptop( int invNumber[], String laptopName[], int invUnits[], double invValue[] )
			laptopNums = invNumber; // store laptop inventory
			laptopNames = laptopNames; // store laptop unique names
			laptopUnits = invUnits; // store number of laptops
			laptopValue = invValue; // store unit price for each laptops
	public double calcInventoryValue()
			// calculate Inventory value
			totalValue = 0; // Initialize totalValue variable
			for ( int count = 0; count < laptopNums.length; count++ )
				runValue = 0; // initialize the runValue
				runValue = ( laptopUnits[ count ] * laptopValue [ count ] );
			System.out.printf( "%s%d%s%s%s%d%s%.2f%s%.2f\n", "Item #", laptopNums[ count ], " is: ", laptopNames[ count ], " with ", laptopUnits [ count ], " units priced at $", laptopValue [ count ], " gives value of $", runValue );
				totalvalue = totalValue + runValue;
			calcTotalValue( totalvValue );
				return totalValue;
		} // end calcInventoryValue method
		public double calcTotalValue( double totalValue )
			System.out.printf( "%s%.2f\n", "The total value of the inventory is: $", totalValue );
				return totalValue;
		} // end calcTotalValue method
} // end class				

Open in new window

Why are you passing arrays to your contructor parameters?

What you probably want it a class of LaptopInventory, with the array which will hold collection of classes for Laptop for instance. That's one approach. Another approach would be to have an array of Maps of sort to hold laptop properties. With the approach you chose it is also possible to accomplish what you want, with one condition that all parameters will allways be present and nothing will cause array indexes to shift.

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now