0

Fig.2.7: Inventory.java

// Inventory program 


import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import javax.swing.JOptionPane; 

public class Inventory {
	
	private static double totInventoryValue = 0;
	
	public static void main( String arg[] ){
		
		product invProd[] = new product[3];
		
		Scanner input = new Scanner( System.in );
		
		for (int iter = 0; iter < 3 ; iter++){
			
			invProd[iter] = new product();
			
			System.out.println("Enter the Product name"  );
			invProd[iter].setProdName(input.nextLine());
						
			System.out.println("Enter the Product number");
			invProd[iter].setItemNumber(input.nextInt());
					
			
			System.out.println("Enter the Product units"  );
			invProd[iter].setUnits(input.nextInt());
			
			System.out.println("Enter the Product price"  );
			invProd[iter].setUnitPrice(input.nextFloat());
			
			invProd[iter].setInvValue(invProd[iter].calInvValue(invProd[iter].getUnitPrice(), invProd[iter].getUnits()));
					
			input.nextLine();	
			
					
		}

	public class GUI {
		public static void main(String [] args ) {

			String prodNumber = 0
				JOption.pane.showInputDialog(“ Enter item number: “);

			String prodName = 0
				JOption.pane.showInputDialog( “ Product Name; “);

			String prodStockAmount = 0
				JOption.pane.showInputDialog( “ Product Stock Amount:” );

			String prodPrice = 0
				Joption.pane.showInputDialog( “ Product Price:” );
	
			String prodTotalInventory = 0
				JOption.pane.showInputDialog( “ Product Total Inventory:” );

			String restockFee = 0.05%

			int number1 = Integer.parseInt( prodPrice);
			int number2 = Integer.parseInt( prodStockAmount);
			int number3 = Integer.parseInt( restockFee);

			int amount = number1 * number2; // multiply numbers
			int amount = prodTotalInventory * restockFee:// multiply numbers

			// display result in a JOption message dialog 
			JOption.pane.showMessageDialog( null, “The amount is” * amount, “Amount of two integers” , JOption.Pane.PLAIN_MESSAGE );
		
} end method main

} end class GUI
			
			
		//Call invSort method to sort the product name  
		product[] sortedInvProd = invSort(invProd);
		
		for (int iter = 0; iter < 3 ; iter++){
			//Call Display method to display the inventory items
			displayInventory(invProd[iter]);
		}
		
		System.out.println("Total Inventory Value :" + totInventoryValue );
	}
	
	public static product[] invSort(product [] invProd)
    {
		product temp[] = new product[1];
         

        for(int j = 0; j < invProd.length - 1; j++)
        {
         
            for(int k = 0; k < invProd.length - 1; k++)
            {
         
                if(invProd[k].getProdName().compareToIgnoreCase(invProd[k+1].getProdName()) > 0)
                {
         
                    temp[0] = invProd[k];
                    invProd[k] = invProd[k+1];
                    invProd[k+1] = temp[0];
         
                }
         
            }
         
        }
        
        return invProd;
    }



	   private static void displayInventory(product product) {
		
		System.out.println("Inventory Number " + product.getItemNumber() + "\nName " + product.getProdName());
		System.out.println("Units " + product.getUnits() + "\nInventory Price " + product.getUnitPrice());
		System.out.println("Product Inventory Value " + product.getInvValue());
		totInventoryValue = totInventoryValue + product.getInvValue();
		
	}
	

}


public class Title extends Object {
	
	private String titleName;
	private String prodPrice;
private String prodNumber;
private String prodInventory;
private double restockFee; // restock percentage


//set grossInventory
public void setGrossInventory {

  
   grossInvenotry = (stockAmount < 0 : Inventory
} // end method set gross Inventory


	   return grossInventory
	public returnGrossInventory ()

	return grossInventory
	} // end method returnGrossInventory

  	// set restockFee
	public void set restockFee (double) {
	
	   restockFee =  ( rate > 0.0 && rate < 0.05 ): 0.0;
	} // end method set restockFee

	// return restockFee
	public double returnRestockFee ()

	return restockFee
 	} // end method returnRestockFee

	// calculate restockFee
	public double restockFee ()
	{ 
	
Return restockFee * grossInventory
	} // end method calculate restockFee
	
	


public class product {
	int	itemNumber;
	String prodName;
	int units;
	double unitPrice;
	double invValue;
	
	public int getItemNumber() {
		return itemNumber;
	}
	public void setItemNumber(int itemNumber) {
		this.itemNumber = itemNumber;
	}
	public String getProdName() {
		return prodName;
	}
	public void setProdName(String prodName) {
		this.prodName = prodName;
	}
	public int getUnits() {
		return units;
	}
	public void setUnits(int units) {
		this.units = units;
	}
	public double getUnitPrice() {
		return unitPrice;
	}
	public void setUnitPrice(double price) {
		this.unitPrice = price;
	}
	
	public double calInvValue(double price, int units){
		return invValue = price * units;
	}
	public double getInvValue() {
		return invValue;
	}
	public void setInvValue(double invValue) {
		this.invValue = invValue;
	} 
	
				

}
2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ezzaral
0

How should we know? Is it doing what you expect it to do? If not, what is wrong with it? Be specific.

If you want someone to read it, you need to post it in [code]

[/code] tags so the indentation is preserved instead of that wall of unformatted mess.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.