Modify the inventory program to use a gui


Discuss the below:

Q: Modify the Inventory Program to use a GUI. The GUI should display the information one product at a time, including 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 of that product. In addition, the GUI should display the value of the entire inventory, the additional attribute, and the restocking fee.public class Products
{
public static double valueOfInventory(double p, int u,boolean isR)
{
double vOfI = p * u;
return (vOfI + valueOfRestockFee(p,u,isR));
}

public static double valueOfRestockFee(double p, int u, boolean isR)
{
double percent = 0;
if(isR) percent = (p * u * 5) / 100;
return percent;
}

}

import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.IOException;


/**
*
* Created by: Alex Kolaris
* Date: Sep 21, 2006
*
*
*/

public class InventoryMain {
public static void main( String[] args){
Inventory p = new Inventory(1, "pencils", 12, 0.5);
Inventory q = new Inventory(2, "Notebooks", 15, 0.5);
Inventory r = new Inventory(3, "pens", 20, 0.6);
///show inventory
Inventory.showInventory();

///show total value of inventory
Inventory.showValueofInventory();

///show sorted Products
Inventory.sortByProduct();

}
}


/**
*
* Created by: Alex Kolaris
* Date: Sep 21, 2006
*
*
*/
public class Inventory {
private static int itemNum[] = new int[3];
private static String name[] = new String[3];
private static int units[] = new int[3];
private static double price[] = new double[3];
private static int i = 0;

public Inventory(){ }//

public Inventory(int _itemNum, String _name, int _units, double _price)//
{
itemNum[i] = _itemNum;
name[i] = _name;
units[i] = _units;
price[i] = _price;
i = i + 1;
}

public static double valueOfInventory(double p,int u)
{
return p*u;
}

public static void showInventory()
{
for(int j=0;j System.out.println("Product Name : " + name[j]);
System.out.println("Item Number : " + itemNum[j]);
System.out.println("Number of Units: " + units[j]);
System.out.println("Unit Price : " + price[j]);
System.out.println("The value of the inventory of " + name[j] + " is = " + valueOfInventory(price[j], units[j]));//call the valueOfInventory() method and display the value
}
}

public static void showValueofInventory()
{
double totalVal = 0;
for (int j = 0; j < i; j++)
{
totalVal = totalVal + valueOfInventory(price[j], units[j]);
}
System.out.println("\n-----------Total Value of Inventory is = " + totalVal);
}

public static void sortByProduct()
{
for (int j = 0; j < i; j++){
int min = j;
for (int k = j; k < i; k++){
if (name[k].compareTo(name[min]) < 0){
min = k;
}
}
sortItems(j, min);
String tmp;
tmp = name[j];
name[j] = name[min];
name[min] = tmp;
}

System.out.println("\n************Inventory sorted by products***********\n");
showInventory();
}

public static void sortItems(int j, int min)
{
int temp = itemNum[j];
itemNum[j] = itemNum[min];
itemNum[min] = temp;

temp = units[j];
units[j] = units[min];
units[min] = temp;

double temp1 = price[j];
price[j] = price[min];
price[min] = temp1;
}

}

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Modify the inventory program to use a gui
Reference No:- TGS01935617

Now Priced at $30 (50% Discount)

Recommended (95%)

Rated (4.7/5)