public class InventoryProgramPart1{
     public static void main (String args []){

     DVD dvd;

     dvd = new DVD(1, "Just Go With It", 8, 2.04);

     dvd = new DVD (2, "Gnomeo and Juliet",  2, 1.34);

     dvd = new DVD (3, "Black Swan", 6, 2.20);

     dvd = new DVD (4, "Zookeeper", 4, 1.49);

     System.out.println("Products Title is " + dvd.getDvdTitle());
     System.out.println("Number of units in stock is" + dvd.getDvdStock());
     System.out.println("Price of each DVD is" + dvd.getDvdPrice());
     System.out.println("Item number is" + dvd.getDvdItem());
     System.out.println("Value of the inventory is" + dvd.value());

}// end main

}// end class InventoryprogramPart1

class DVD{
    private String dvdTitle;
    private double dvdStock;
    private double dvdPrice;
    private double dvdItem;

    public DVD(String title, double stock, double price, double item){
        dvdTitle = title;
        dvdStock = stock;
        dvdPrice = price;
        dvdItem = item;

    }// end constuctor

    // set DVD name
    public void set dvdTitle(String title){
    }//end method setDvdTitle

    //return DVD Title
    public String getdvdTitle(){
        return dvdTitle;
    }//end method getDvdTitle

    //set DVD Stock
    public void setdvdStock(double stock){
        dvdStock = stock;
    }//end method setDvdStock

    //return DvdStock
    public double getdvdStock(){
        return dvdStock;
    }//end method get DvdStock

    public void setdvdPrice(double price){
        dvdPrice = price;
    }//end method setDvdPrice

    //return dvdPrice
    public double getdvdPrice() {
        return dvdPrice;
    }//end method getDvdPrice

    public void setdvdItem(double item){
        dvdItem = item;
    }//end method setDvdItem

    //return dvdItem
    public double getdvdItem(){
    }//end method getDvdItem

    //calculate the inventory value
    public double value(){
        return dvdPrice * dvdStock;
    }//end method value

}//end class DVD

Right now I'm recieving two errors that I can't just simply figure out. First error is on line 54 I get an expected error '(' I'm not to sure how to go about solving this and another error is on line 87 I'm getting the error "Not a statement". Can anyone help me shed some light on how to figure this out?

Recommended Answers

All 7 Replies

Actually the error is on line 43 and the other error is on line 76.

I found the error that was on line 76, silly me forgot to space out the return. Although I cannot find what's wrong on line 43.

Space after "set"

After I took the space out I recieved 11 errors. Which are all the same. Imcompatiable types: int cannot be converted to string in line 6,9,10,12,13,15, and in line 16 error: package system does not exists. line 18: error cannot find symbol

I'm thinking something is wrong with my constructor because I'm getting the error constructor DVD in class DVD cannot be applied to given types

I am so lost right now

The specific error is that I have "dvd= new DVD" which is telling me the constructor cannot be applied

in your constructor, you have the parameters set like this:

public DVD(String title, double stock, double price, double item)

but you call it like this:

dvd = new DVD(1, "Just Go With It", 8, 2.04);
dvd = new DVD (2, "Gnomeo and Juliet",  2, 1.34);

the title should be the first parameter. I'm not sure what you're trying to pass, but the 1 and 2 which you try to pass as first parameter, seems to me like it's supposed to be an id. try like this:

dvd = new DVD("Just go with it", 8, 2.04, 1);
dvd = new DVD ("Gnomeo and Juliet",  2, 1.34, 2);

just a remark: the id and the number of elements in stock can never be a number with decimals, so you shouldn't use a double for them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.