Massive thunderstorm here right now, I am trying to get off before I lose power. I have an array that is accepting inventory input from the user. The value of each product is figured as it is entered, simple instock number muliplied by the product value.
I simply want to sum that value at the end of the array for a total inventory value.
Here is my code:
public class Compactdisk
{// begin class
//InventoryCD class has 5 fields
String Name; // Name of cd
float price; // price of cd
int itemno; // item number of cd
int nstock; // how many units in stock
int cdCount; // cd counter for array
float value; // value for single cd inventory
float totalValue; // value for entire inventory
//Compact disk class constructor
public Compactdisk()
// 4 fields need to be set up
{
Name = "";
price = 0;
itemno = 0;
nstock = 0;
cdCount = 0;
value = 0;
totalValue = 0;
}
// set values
public void setName(String diskName)
{
Name = diskName;
}
public void setPrice(float cdPrice)
{
price = cdPrice;
}
public void setItemno(int cdItemno)
{
itemno = cdItemno;
}
public void setNstock(int cdStock)
{
nstock = cdStock;
}
public void setValue(float cdValue)
{
value = cdValue;
}
public void setcdCount(int Count)
{
cdCount = Count;
}
public void setTotalValue(float invValue)
{
totalValue = invValue;
}
// return values
public String getName()
{
return (Name);
}
public float getPrice()
{
return (price);
}
public int getItemno()
{
return (itemno);
}
public int getNstock()
{
return (nstock);
}
// returns indivudual inventory value for a disk
public float getValue()
{
return(price * nstock);
}
// returns total inventory value for all disks
public float getTotalValue()
{
return (totalValue += cds[cdCount].getValue());
}
}// end class
I am getting these two errors back:
Compactdisk.java:86: cannot find symbol
symbol : variable cds
location: class Compactdisk
return (totalValue += cds[cdCount].getValue());
^
Compactdisk.java:86: inconvertible types
found : <nulltype>
required: float
return (totalValue += cds[cdCount].getValue());
^
2 errors
I thought this would be simple, but I have played with these parameters and formulas for 10 to 12 hours now with no progress? I think I have it close, but just do not see what I am doing wrong.
Am I just way off base and not skilled enough to know it?
Any help would be appreciated.