Please could someone help with this Project thank you and would also be much appreciated.

CD Collection
Write a program that stores details of a CD collection.
Level 1 maximum 50% (depending on implementation, demonstration, viva and documentation) must include the following:
 Declaration and initialisation of variables
 Separate arrays to store individual details of each item
 A menu of options dependent on an integer variable
 Method to add items
 Method to search for an item and print details
 Method to print items
 Useful comments, good indentation, good use of variable names

Example
• Create a menu of options controlled with an integer variable for the programme including
o input a new entry from a keyboard
o search for an entry
o print all the entries so far
o Quit
• Declare a series of arrays to hold details of CDs. A CD consists of (for example) the title, number of tracks, artist, (“Superstition”, 20, “Stevie Wonder”). The program should be able to store CD details in the declared arrays.
• A single entry can be entered by the user typing the details in and the entry can be printed out.
• Your program should provide a search method that allows the title of a given CD to be looked up in the array and the details printed to the screen.

Level 2 version A - maximum 100% (depending on implementation, demonstration, viva and documentation) must include the following:
As level 1 above plus
 Method to update an entry
 Method to sort items by artist (Hint use an index array for this).
 Method to save data to a file
 Method to retrieve data from a file

Example
As Level 1 example plus
• Expand menu with additional options and write code for the following:
• An entry can be updated
• Data can be sorted by artist and entries displayed in that order to the screen
• Data can be stored in a text file
• Data can be retrieved into the array from a text file

don't expect quick solutions to your homework. We'll help you get started and exchange algorithm ideas, but only if you show that you're willing to put in effort as well.

ps: This is an incredibly badly designed exercise. Using a "series of arrays" is as far from good Java design as it is possible to be, and sets you off in a completely wrong direction. You'll be solving problems that have no practical use. 0/10 for your teacher.
Anyway, I guess you have no choice. So, in line with DaniWeb policy, put in some effort, and we'll help.

ps: This is an incredibly badly designed exercise. Using a "series of arrays" is as far from good Java design as it is possible to be, and sets you off in a completely wrong direction. You'll be solving problems that have no practical use. 0/10 for your teacher.
Anyway, I guess you have no choice. So, in line with DaniWeb policy, put in some effort, and we'll help.

plz reply bk

public static void main(String[] args)  throws IOException
    {
            final int ARRAYSIZE = 8;
            Cd[] cdCollection = new Cd[ARRAYSIZE];  //create object


public static void add( int i ,Cd[] cdCollection)

    {
        //Cd Class..details are left behind..i did initialise all of em..

            cdCollectiont[i] = new Cd();

            cdCollection[i].title = JOptionPane.showInputDialog("Enter the Title");
            cdCollection[i].year = Integer.parseInt(JOptionPane.showInputDialog("Enter the Year"));
            cdCollection[i].venue= JOptionPane.showInputDialog("Enter the Venue");

            cdCollection[i].printSport();

i++;
        //array of object..I think dont work..the positon is always returned as 0..in linear search

    }   



public static void search(CD[] cdCollection)
    {
        String search = JOptionPane.showInputDialog("search");

        int result = linearSearch(cdCollection, search);

        if (result == -1)
            {

            System.out.println("Sorry " + search + " , not found");

            }       

        else 
            {

            System.out.println("Search " + search + " found at position " + result);
            }


    }

    public static int linearSearch(CD cdCollection[], String KE )
    {

        for (int i =0; i< cdCollection.length; i++)
        {   


        if (cdCollection[i].title.equals(kE))   
        return i; 
                if (cdCollectiont[i].year.equals(kE)) 
//i get null exception or either int cannot be dereferenced...but this is objects...i did initialise int in my class ..also tried to use toString()..just doesnot work..at all..
                return i;
               if (cdCollection[i].venue.equals(kE))
                return i;

        }
        return (-1); //this doesnt seem to work too..
    }






...

PLease Help

@Naruto1
Your code is irrelevant to the OP's stated requirement. If you have a question about your own homework create a new thread of your own; do not hijack someone else's thread.

I'm not going to read through all of that, since
1. you're not the original poster of this thread, which means you're likely someone handing out a quick sollution that you think fit the needs (actually hope in this case I'm wrong)
2. you didn't put your code between code tags, which makes it very difficult to read
3. well .. I read the first line and got a 'woooops' thought stuck in my mind.

why are you throwing that IOException to? after the main method, there's no other place you can actually catch the exception and generate an error message for the user.
this is the place you'll want to catch your exceptions (if not done somewhere before it got to this point) into a try-catch block.

a next point of issue: very important!

you can not declare a method within a method. you have to close your main method before declaring your add method.
if you want to use add within your main, you'll have to call it.

@Naruto1
Your code is irrelevant to the OP's stated requirement. If you have a question about your own homework create a new thread of your own; do not hijack someone else's thread.

I love it how one homework kiddo hijacks another :) Less threads for the moderators to remove.

plz reply bk

good luck with your homework. Do tell us how you succeeded.

plz reply bk

You're not listening... I'll say this one more time...
"in line with DaniWeb policy, put in some effort, and we'll help."

lol..i wasnt really highjacking..was trying to help the thread creator..while asking for assistance. Thanks..anyway.:P
I will create a new thread..asking for my own help . THankx.

lol..i wasnt really highjacking..was trying to help the thread creator..while asking for assistance. Thanks..anyway.:P
I will create a new thread..asking for my own help . THankx.

The sad thing for the OP is that your approach - with a CD class that encapsulates all the attributes of a CD - is the "right" way to do this. Unfortunately the way his project has been defined doesn't allow him to do that.
Anyway, see you in your new thread.
J

Be a part of the DaniWeb community

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