help with an array



This is what I have done so fare but I need to use an array to store
items. The output needs to 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 output should display the value of
the entire inventory. I have done this last part but it only brings up
0.0 instead of the total.

// This calls the external class scanner
import java.util.Scanner;


// This is the class to hold things
class inventory
{ // start of class

// Variable Declaration
private String productname; // name of movie
private double productnumber; // product number
private double numberinstock; // number of movie in stock
private double priceofitem; // the price of the movie



// gets the product name

public void getproductname(String productname)
{
productname = productname;
}
// gets the product number
public void setproductnumber(double productnumber)
{
productnumber = productnumber;
}
public double getproductnumber()
{
return productnumber;
}
// gets the number in stock
public void setnumberinstock(double numberinstock)
{
numberinstock = numberinstock;
}
public double getnumberinstock()
{
return numberinstock;
}
// gets the price of the item
public void setpriceofitem(double priceofitem)
{
priceofitem = priceofitem;
}
public double getpriceofitem()
{
return priceofitem;
}

// This calculates the value of inventory, but i can not get it
to work
public double value()
{
return numberinstock * priceofitem;
}

} // end of class
*****************************************************************
// This calls the external class scanner
import java.util.Scanner;


public class whatever
{ // starts the class

public static void main( String args[])
{ // starts the program
Scanner input = new Scanner( System.in );

inventory myinventory = new inventory();

// get the name of the movie
System.out.printf( "\n\nEnter the name of the movie, enter stop
when done):");
String productname = (input.next());
while(!productname.equals("stop"))
{ // should start the loop

// gets the product number for the movie
System.out.printf( "\nEnter the product number: " );
myinventory.setproductnumber(input.nextDouble());

// gets the number you are puting into stock
System.out.printf( "\nEnter the number in stock: ");
myinventory.setnumberinstock(input.nextDouble());

// gets the price of the movie
System.out.printf( "\nEnter the items price: ");
myinventory.setpriceofitem(input.nextDouble());

// this should show the value of the inventory
System.out.printf( "\n\nThis is what the value of the inventory
should be: $ "+ myinventory.value());

// get the name of the movie
System.out.printf( "\n\nEnter the name of the movie, enter stop
when done):");
myinventory.getproductname(input.next());

} // should end the loop

} // end of program

} // end of class

.



Relevant Pages

  • Re: score one for sanity
    ... You give them a DVD or VHS of a movie that you ... The businesses also must turn over their inventory to the movie studios ... movies for scrubbing. ...
    (alt.marketing.online.ebay)
  • Re: union query with form critera
    ... movie has a DVD/VHS, etc. ... book_inventory.sold_price)=0) Inventory ... book_inventory.sold_price)>0) Sold ...
    (microsoft.public.access.reports)
  • Re: score one for sanity
    ... You give them a DVD or VHS of a movie that you ... The businesses also must turn over their inventory to the movie studios ...
    (alt.marketing.online.ebay)
  • Re: AWD?
    ... Supposedly we got a diesel converted versions of the KLR650 floating around ... somewhere in the inventory... ... Hell you were probably in the movie. ... DirtCrashr - ...
    (rec.motorcycles.dirt)