import java.util.Scanner;
import java.util.Arrays;
import java.lang.String;
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]);
}
Arrays.sort(Supplies[);
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