Easy variable issue...
I have an easy question but am having a mental block. How can I assign the value of 0.05 to restock? What I need to do is return a 5% restocking value added onto the item. Make sense?
//Type.java
publicclass Typeextends Office// Start of public subclass Itemtype that stores office items color.
{
private String color;//get string name
privatefloat restock;//get float value of restock
privatefloat item;//get float value of total items
public Type(String color,float restock,float item)
{// constructor to initialize the fields
this.color = color;
this.restock = restock;
this.item = item;
}
publicfloat getRestock()
{
return (this.item * this.restock) + (this.item);
}
}//end public subclass Type
[1663 byte] By [
Jack1971a] at [2007-10-3 3:47:51]

Ok here is what I have, an inventory program called Office.....see below
//Inventory.java
import java.util.*; //imports java utilities to include Array.sort function.
public class Office
{ //start of main
public static void main( String args[] )
{ //start of class
int array[] = { 1, 2, 3, 4, 5, }; //creates number array
String item[] = {"Pencil" , "Pen" , "Toner" , "Ink" , "Paper"}; //creates item array
int stock[] = { 5, 8, 6, 5, 4}; // creates stock array
int price[] = { 1, 2, 33, 12, 4}; //creates price array
System.out.printf( "0%s%8s%8s%8s\n", "Number", "Item", "Stock", "Price"); //displays columns
double itemInv = 0.00; //item's value variable
double totalInv = 0.00;//total inventories variable
double restock = 0.05;
for ( int counter = 0; counter < item.length; counter++ ) //start of for loop
{
Arrays.sort(item); //sorts array according to item name alphabetically
itemInv = (stock [ counter ] * price [ counter ]); //method to calculate items inventory value
System.out.printf( "%5d%8s%8d%8d\n", counter, item [ counter ], stock [ counter ], price [ counter ]);//display lists of items
totalInv += (stock [ counter ] * price [ counter ]);//method to calculate inventories total value
System.out.println("Total value = $" + totalInv);//displays inventories total value
} //end of class
} //end main
} //end of main
And I need to use a subclass to store a unique feature and return a 5% restocking value to each items inventory. This is the subclass I created.... I could be way off, this stuff is very new to me. :) Please forgive..lol
[code]
//Type.java
public class Type extends Office // Start of public subclass Itemtype that stores office items color.
{
private String color; //get string name
private float restock;//get float value of restock
private float item;//get float value of total items
public Type(String color,float restock, float item)
{ // constructor to initialize the fields
this.color = color;
this.restock = restock;
this.item = item;
}
public float getRestock()
{
return (this.item * this.restock) + (this.item);}
{System.out.println("Restock Value = $" + restock);
}
} //end public subclass Type