import java.util.Scanner;
import java.util.Arrays;
import java.lang.String;
import static java.lang.System.out;
import javax.swing.*;
// all imports for program
public class InventoryProgram
{
// main method begins program execution
public static void main(String args[] )
{
// display a welcome message to the InventoryProgram to user
System.out.println( "Welcome to Inventory Program!" );
// work supplies (names of chemicals used pirces are made up cause I don't know them.
Supplies[] supplies = new Supplies[100]; // an array of 100 supplies
Supplies Maverick = new Supplies( 001, "Maverick", 60, 2.75 );
Supplies Termidor = new Supplies( 002, "Termidor", 75, 1.25 );
Supplies Bithor = new Supplies( 003, "Bithor", 30, 4.75 );
Supplies Demon = new Supplies( 004, "Demon", 15, 5.25 );
Supplies DeltaDust = new Supplies( 005, "Delta Dust", 45, 3.50 );
for (int i=0; i>100; i++){
System.out.println("Supplies" +0+ ":" +supplies[0]);
}
for (int i=0; i>100; i++);{
System.out.println("Supplies" +100+ ":" +supplies[0]);
}
// display the inventories one at a time
Maverick.showInventory();
Termidor.showInventory();
Bithor.showInventory();
Demon.showInventory();
DeltaDust.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!\n" );
} // end method main
} // end class InventoryProgram
// Office Supplies
class Supplies
{
private int SuppliesNumber;
private String SuppliesName = new String();
private int SuppliesUnits;
private double SuppliesPrice;
// set supplies number
public void setSuppliesNumber( int number )
{
this.SuppliesNumber = number;
} // end method set supplies number
// return supplies number
public float 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() );
// Display value plus restocking fee
//System.out.printf( "\nInventory value of "supplies[f],suppliesName" is = $%.2f\n",
//getRestockingFee());
} // end method display inventory
}// end class manufacturer
package my.inventoryGUI; //starts my GUI
public class InventoryGUI extends javax.swing.JFrame {
// Creates new form InventoryGUI
public InventoryGUI() {
initComponents();
}
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextPane1 = new javax.swing.JTextPane();
jPanel2 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jScrollPane2 = new javax.swing.JScrollPane();
jTextPane2 = new javax.swing.JTextPane();
jScrollPane3 = new javax.swing.JScrollPane();
jTextPane3 = new javax.swing.JTextPane();
jScrollPane4 = new javax.swing.JScrollPane();
jTextPane4 = new javax.swing.JTextPane();
jButton1 = new javax.swing.JButton();
jScrollPane5 = new javax.swing.JScrollPane();
jTextPane5 = new javax.swing.JTextPane();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jScrollPane6 = new javax.swing.JScrollPane();
jTextPane6 = new javax.swing.JTextPane();
jLabel6 = new javax.swing.JLabel();
jScrollPane7 = new javax.swing.JScrollPane();
jTextPane7 = new javax.swing.JTextPane();
jScrollPane1.setViewportView(jTextPane1);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(40, 40, 40)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(60, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 78, Short.MAX_VALUE))
);
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
jLabel1.setText("Product Name");
jLabel2.setText("Item Number");
jLabel3.setText("Number in Stock");
jScrollPane2.setViewportView(jTextPane2);
jScrollPane3.setViewportView(jTextPane3);
jScrollPane4.setViewportView(jTextPane4);
jButton1.setText("Exit");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jScrollPane5.setViewportView(jTextPane5);
jLabel4.setText("Price per Unit");
jLabel5.setText("Price with Restock Fee");
jScrollPane6.setViewportView(jTextPane6);
jLabel6.setText("Total inventoy with restock fee");
jScrollPane7.setViewportView(jTextPane7);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton1))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6))
.addGap(33, 33, 33)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jScrollPane7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)
.addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane4, javax.swing.GroupLayout.Alignment.LEADING)))
.addGap(0, 82, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(20, 20, 20)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel4))
.addGap(18, 18, 18)
.addComponent(jLabel5))
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
.addComponent(jLabel6))
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jScrollPane7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(18, 18, 18)
.addComponent(jButton1)
.addContainerGap())
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(56, Short.MAX_VALUE))
);
pack();
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
public static void main(String args[]) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getSupplies());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(InventoryGUI.class.getSupplies()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(InventoryGUI.class.getSupplies()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(InventoryGUI.class.getSupplies()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(InventoryGUI.class.getSupplies()).log(java.util.logging.Level.SEVERE, null, ex);
}
// Create and display the form
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new InventoryGUI().setVisible(true);
}
});
}
// Variables declaration
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JScrollPane jScrollPane7;
private javax.swing.JTextPane jTextPane1;
private javax.swing.JTextPane jTextPane2;
private javax.swing.JTextPane jTextPane3;
private javax.swing.JTextPane jTextPane4;
private javax.swing.JTextPane jTextPane5;
private javax.swing.JTextPane jTextPane6;
private javax.swing.JTextPane jTextPane7;
}
// End of variables declaration