There are errors in lines : 9,14,28,47,,49,38 & 66 please can u give me solutions to these and thank for reading this.

CdRecord[] arrayrecord=new CdRecord[5];

int counter = 0;
int result;

CdRecord one = new CdRecord();

menu_choice=Integer.parseInt(JOptionPane.showInputDialog("Enter 1 to create cd"
+ "\nEnter 2 to print"
+ "\nEnter 3 to search"
+ "\nEnter 4 to quit" ));

while (menu_choice != 4)

{
if (menu_choice ==1 )
JOptionPane.showMessageDialog(null,"");
{

Record[counter] = new CdRecord();
counter++;
//for int (i)
}


if (menu_choice==2)
//JOptionPane.showMessageDialog(null,"");
{
for(int i=0;i<counter;i++)
Record[i].toString();
}

else if (menu_choice ==3)
//JOptionPane.showMessageDialog(null,"");
{

String searchKey =JOptionPane.showInputDialog("Please enter the model of the vehicle");

result=CdSearch(CdRecord,searchKey,counter);
if (result >= 0) // a valid array index
CdRecord[result].CdRecord();

else
JOptionPane.showMessageDialog(null,"KEY " + searchKey + " NOT FOUND");
}

menu_choice=Integer.parseInt(JOptionPane.showInputDialog("Enter 1 to create cd"
+ "\nEnter 2 to print"
+ "\nEnter 3 to search"
+ "\nEnter 4 to quit" ));


}

// System.out.println(one.toString());

}
public static int CdSearch (CdRecord [] data, String searchKey, int size)
{
for (int counter = 0; counter <size; counter++)
{
if (data[counter].toString().equals(searchKey))
return counter; // return position where found
}

return -1; // if drop off end of array, its not there
}


}

Recommended Answers

All 4 Replies

I don't know where the errors are but they can't be lines 14 and 38 because those are blank. You need to indent so the code is readable. You also need to post the exact error messages and the correct line numbers.

I don't know where the errors are but they can't be lines 14 and 38 because those are blank. You need to indent so the code is readable. You also need to post the exact error messages and the correct line numbers.

sorry i will resend da coding i made a mistake. Problems:
Line 10,15,29,67 - CdRecord cannot be a resolved to a type.
Line 48 & 50 CdRecord cannot be a resolved to a variable
Line 29 & 39 Record cannot be resolved to a variable

import javax.swing.JOptionPane;

class NewCd
{
public static void main (String[] args)
{
int menu_choice;

CdRecord[] arrayrecord=new CdRecord[5];

int counter = 0;
int result;

CdRecord one = new CdRecord();

menu_choice=Integer.parseInt(JOptionPane.showInputDialog("Enter 1 to create cd"
+ "\nEnter 2 to print"
+ "\nEnter 3 to search"
+ "\nEnter 4 to quit" ));

while (menu_choice != 4)

{
if (menu_choice ==1 )
JOptionPane.showMessageDialog(null,"");
{

Record[counter] = new CdRecord();
counter++;
//for int (i)
}


if (menu_choice==2)
//JOptionPane.showMessageDialog(null,"");
{
for(int i=0;i<counter;i++)
Record[i].toString();
}

else if (menu_choice ==3)
//JOptionPane.showMessageDialog(null,"");
{

String searchKey =JOptionPane.showInputDialog("Please enter the model of the vehicle");

result=CdSearch(CdRecord,searchKey,counter);
if (result >= 0) // a valid array index
CdRecord[result].CdRecord();

else
JOptionPane.showMessageDialog(null,"KEY " + searchKey + " NOT FOUND");
}

menu_choice=Integer.parseInt(JOptionPane.showInputDialog("Enter 1 to create cd"
+ "\nEnter 2 to print"
+ "\nEnter 3 to search"
+ "\nEnter 4 to quit" ));


}

// System.out.println(one.toString());

}
public static int CdSearch (CdRecord [] data, String searchKey, int size)
{
for (int counter = 0; counter <size; counter++)
{
if (data[counter].toString().equals(searchKey))
return counter; // return position where found
}

return -1; // if drop off end of array, its not there
}


}

still need the error messages

or just a quick scan of the code ...
you try to use variables, but you don't use the names that you initialized them with.

since you never declared a variable with the name Record, it should be quite clear why you can not use it.

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.