Link to home
Start Free TrialLog in
Avatar of pogibear77
pogibear77

asked on

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.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of contactkarthi
contactkarthi
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pogibear77
pogibear77

ASKER

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

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial