Welcome to Dream.In.Code
Click Here
Getting Java Help is Easy!

Join 118,659 Java Programmers for FREE! Ask your question and get quick answers from experts. There are 864 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Inventory Program help.

 
Reply to this topicStart new topic

Inventory Program help.

maximus32
post 1 Jul, 2008 - 07:56 PM
Post #1


New D.I.C Head

*
Joined: 1 Jul, 2008
Posts: 8

Here is what i have so far for the first part of my Inventory Program part 1

Here is the assignment:

*Choose a product that lends itself to an inventory (for example, products at your
workplace, office supplies, music CDs, DVD movies, or software).

*Create a product class that holds the item number, the name of the product, the number
of units in stock, and the price of each unit.

*Create a Java application that displays: the product number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory (the number of units in stock multiplied by the price of each unit). Pay attention to the good programming practices in the text to ensure your source code is readable and well
documented.

Here is what i have so far, What am i missing? Any help would be highly appreciated.
Thanks in advance.

java

package inventoryprogrampart1;
// MY DVD CLASS

public class inventoryprogrampart1
{
private static DVDINVENTORY NEW;
// Display DVDNAME, DVDNUMBER,DVDUNITS,DVDCOSTS & INVENTORYVALUE
public static void main(String[] args){
String DVDNAME;
String DVDNUMBER;
String DVDUNITS;
double DVDCOST;
double INVENTORYVALUE = 0;// inventoryvalue of DVDUNITS * DVDCOST

System.out.println("Enter DVDNAME:");
System.out.println("Enter DVDNUMBER:");
System.out.println("Enter DVDUNITS:");
System.out.println("Enter DVDCOST:");


INVENTORYVALUE = DVDUNITS * DVDCOST; // multipy numbers
System.out.printf("INVENTORYVALUE = $%.2f\n",INVENTORYVALUE);
}
}


class DVDINVENTORY
{
private String DVDName;
private String DVDNumber;
private int DVDUNITS;
private double DVDCOST;
private double INVENTORYVALUE;

// Constructor to get information
public DVDINVENTORY(String DVDName, String DVDNumber, int DVDUNITS, double DVDCOST, double INVENTORYVALUE) {
this.DVDName = DVDName;
this.DVDNumber = DVDNumber;
this.DVDUNITS = DVDUNITS;
this.DVDCOST = DVDCOST;
this.INVENTORYVALUE = INVENTORYVALUE;

}
public String getDVDName() {
return DVDName;
}
public void setDVDName(String DVDName) {
this.DVDName = DVDName;
}
public String getDVDNumber() {
return DVDNumber;
}
public void setDVDNumber(String DVDNumber) {
this.DVDNumber = DVDNumber;
}
public int getDVDUNITS() {
return DVDUNITS;
}
public void setDVDUNITS(int DVDUNITS) {
this.DVDUNITS = DVDUNITS;
}
public double getDVDCOST() {
return DVDCOST;
}
public void setDVDCOST(double DVDCOST) {
this.DVDCOST = DVDCOST;
}
public void setINVENTORYVALUE(double INVENTORYVALUE) {
this.INVENTORYVALUE = INVENTORYVALUE;
}

}

*edit: Please use code tags in the future, thanks! code.gif

This post has been edited by Martyr2: 5 Jul, 2008 - 11:26 AM
User is offlineProfile CardPM

Go to the top of the page


pbl
post 1 Jul, 2008 - 08:36 PM
Post #2


D.I.C Lover

Group Icon
Joined: 6 Mar, 2008
Posts: 2,333



Thanked 135 times

Dream Kudos: 75
My Contributions


OK let us start by de beginning
Please post your code like this: code.gif

Usually in Java CAPITALIZED letters are not welcome but it is OK

CODE

class DVD {
   String title;
   int quantity;
   double price;

   // Constructor
   DVD(String title, int quantity, double price) {
       this.title = title;
       this.quantity = quantity;
       this.price = price;
   }
   // getters method
  String getTitle() {
     return title;
  }
  int getQuantity() {
     return quantity;
  }
  double getPrice() {
      return price;
  }
  // OK a method to test all that
  public static void main(String[] arg) {
     // build an array of 3 DVD
     DVD[] dvd = new DVD[3};
     dvd[0] = new DVD("Bridge on River Kway", 10, 10.00);
     dvd[1] = new DVD("Where Eagles dare", 5, 15.00);
     dvd[2] = new DVD("Battle of Britain", 5, 8.00);
     // loops throw this array for total Inventory item and value
     int totalItem = 0;
     double totalValue = 0.0;
     for(int i = 0; i < dvd.length; i++) {
         totalItem += dvd[i].getQuantity();
         totalValue += (dvd[i].getQuantity() * dvd[i].getPrice();
    }
    // print results
    System.out.println("Total number of DVDs in stock: " + totalItem);
    System.out.println("Total value in stock $ " + totalValue);
  }
}

User is offlineProfile CardPM

Go to the top of the page

maximus32
post 2 Jul, 2008 - 05:29 AM
Post #3


New D.I.C Head

*
Joined: 1 Jul, 2008
Posts: 8

CODE

// MY DVD CLASS

public class inventoryprogrampart1
{
private static DVDINVENTORY NEW;
// Display DVDNAME, DVDNUMBER,DVDUNITS,DVDCOSTS & INVENTORYVALUE
public static void main(String[] args){
String DVDNAME;
String DVDNUMBER;
String DVDUNITS;
double DVDCOST;
double INVENTORYVALUE = 0;// inventoryvalue of DVDUNITS * DVDCOST

System.out.println("Enter DVDNAME:");
System.out.println("Enter DVDNUMBER:");
System.out.println("Enter DVDUNITS:");
System.out.println("Enter DVDCOST:");


INVENTORYVALUE = DVDUNITS * DVDCOST; // multipy numbers
System.out.printf("INVENTORYVALUE = $%.2f\n",INVENTORYVALUE);
}
}


class DVDINVENTORY
{
private String DVDName;
private String DVDNumber;
private int DVDUNITS;
private double DVDCOST;
private double INVENTORYVALUE;

// Constructor to get information
public DVDINVENTORY(String DVDName, String DVDNumber, int DVDUNITS, double DVDCOST, double INVENTORYVALUE) {
this.DVDName = DVDName;
this.DVDNumber = DVDNumber;
this.DVDUNITS = DVDUNITS;
this.DVDCOST = DVDCOST;
this.INVENTORYVALUE = INVENTORYVALUE;

}
public String getDVDName() {
return DVDName;
}
public void setDVDName(String DVDName) {
this.DVDName = DVDName;
}
public String getDVDNumber() {
return DVDNumber;
}
public void setDVDNumber(String DVDNumber) {
this.DVDNumber = DVDNumber;
}
public int getDVDUNITS() {
return DVDUNITS;
}
public void setDVDUNITS(int DVDUNITS) {
this.DVDUNITS = DVDUNITS;
}
public double getDVDCOST() {
return DVDCOST;
}
public void setDVDCOST(double DVDCOST) {
this.DVDCOST = DVDCOST;
}
public void setINVENTORYVALUE(double INVENTORYVALUE) {
this.INVENTORYVALUE = INVENTORYVALUE;
}

}
User is offlineProfile CardPM

Go to the top of the page

prajayshetty
post 4 Jul, 2008 - 12:07 PM
Post #4


D.I.C Head

Group Icon
Joined: 27 Apr, 2007
Posts: 223



Dream Kudos: 25
My Contributions



CODE

INVENTORYVALUE = DVDUNITS * DVDCOST;

check this line in your code
how is it possible??
where DVDUNIT is string and second thing u are not accepting any input then why are these statements
CODE


System.out.println("Enter DVDNAME:");
System.out.println("Enter DVDNUMBER:");
System.out.println("Enter DVDUNITS:");
System.out.println("Enter DVDCOST:");

User is offlineProfile CardPM

Go to the top of the page

Locke37
post 4 Jul, 2008 - 12:50 PM
Post #5


I'm not a thief...I prefer the term TREASURE HUNTER!

Group Icon
Joined: 20 Mar, 2008
Posts: 579



Thanked 20 times

Dream Kudos: 300
My Contributions


To prajayshetty, in your signature, you made a syntax error, so I'll give you the answer.

"System.out.println("Try Try till you succeed");"

You forgot the semicolon smile.gif tongue.gif
User is offlineProfile CardPM

Go to the top of the page

prajayshetty
post 4 Jul, 2008 - 12:56 PM
Post #6


D.I.C Head

Group Icon
Joined: 27 Apr, 2007
Posts: 223



Dream Kudos: 25
My Contributions


its just for show so there fore i dont put those semicolon locke
User is offlineProfile CardPM

Go to the top of the page

Locke37
post 4 Jul, 2008 - 06:47 PM
Post #7


I'm not a thief...I prefer the term TREASURE HUNTER!

Group Icon
Joined: 20 Mar, 2008
Posts: 579



Thanked 20 times

Dream Kudos: 300
My Contributions


unsure.gif tongue.gif
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/12/08 03:58AM

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month