Results 1 to 2 of 2
  1. #1
    gomdohri is offline Member
    Join Date
    Sep 2011
    Rep Power

    Default re-ordering problem please help me...

    Question: Write a program that maintains information about the inventory of a shop. Each item in the shope has a name, the number of these items the shop currently has and the price of the item in cents. The shop may have possibly many different items in it. The Inventory class must have a totalStockValue() method which returns the sum of all the stock.

    Then, modify the above example such that for each item in the stop you also store: the rate which the item is sold (in units per day) along with the number of days re-ordering takes. use this information to generate a preort of the items that need reordering such that the store does not run out of any itmes ( you may assume that the information you store about each item is correct.


    For the first part, I have finished and the code is:

    import java.util.ArrayList;

    public class Inventory {

    String name;
    int number;
    int price; // in cents
    static int total;

    public Inventory(String name, Integer number, Integer price){ = name;
    this.number = number;
    this.price = price;

    public static void main(String[] args){
    ArrayList<Inventory> list = new ArrayList<Inventory>();

    list.add(new Inventory("Socks",3,234));
    list.add(new Inventory("Glue",5,204));
    list.add(new Inventory("Hole",8,214));
    list.add(new Inventory("Cereal",2,224));
    list.add(new Inventory("Cheese",1,224));

    total = totalStockValue(list);



    public static Integer totalStockValue(ArrayList<Inventory>list){

    int totalPrice = 0;
    for(Inventory h: list){
    totalPrice += (h.number * h.price);

    return totalPrice;

    For later part of the question, I think it is quite easy but because it is late I cannot think properly (it is 3:00 am in Australia right now lol) and I need your help.

    All we need to do is to add a function if (itemLeft / dayrate <= orderDays) then return true, which means we need to order right???

    I know that it is quite rude to write a code but could you write a for me please? I need this for 10.00 am EXAM...THANK YOU MASTERS

  2. #2
    gomdohri is offline Member
    Join Date
    Sep 2011
    Rep Power

    Default Re: re-ordering problem please help me...

    Solved don't worry!

Similar Threads

  1. Deciding Interceptor Ordering?
    By arpitgadle in forum Web Frameworks
    Replies: 0
    Last Post: 08-10-2010, 11:55 AM
  2. what is natural ordering???
    By blueduiker in forum New To Java
    Replies: 1
    Last Post: 02-24-2010, 11:51 AM
  3. getting all possible ordering of vector
    By sara12345 in forum New To Java
    Replies: 3
    Last Post: 01-08-2010, 11:21 PM
  4. Problem with ordering for loops
    By ScaryJello in forum New To Java
    Replies: 3
    Last Post: 03-31-2009, 09:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts