Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Compile Error, tried everything please help

  1. #1
    Junior Member
    Join Date
    May 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Compile Error, tried everything please help

    Here's my code. I have an assignment due in an hour and thankfully i found this site before it got too late. Ive been working on this for several hours and cant get this to compile.
    The errors are in lines 23,27,31 ')' expected.

    import java.util.Scanner;
    public class Final
    {
     public static void main(String[] args)
     {
     
       Scanner in = new Scanner(System.in);
     
       boolean again = true;
       int length[] = new int[128];
     
       String titles[] = new String[128];
       int numDVDs = 0;
       boolean quit = false;
     
     
       do
       {
               System.out.println(menu());
               String choice = in.nextLine();
                    if (choice.equalsIgnoreCase("a"))
                    {
       **     ==error           numDVDs = addDVD(String titles[], int length[],int numDVDs);
                    }
                    if (choice.equalsIgnoreCase("t"))
                    {
     **    ==error              searchByTitle(String titles[],int length[], int numDVDs);
                    }
                    if (choice.equalsIgnoreCase("l"))
     {
         **              searchByLength(String titles[],int length[],int numDVDs);
                    }
                    if (choice.equalsIgnoreCase("q"))
                    {
                       quit = true;
                    }
        }while (!quit);
     
        //closes while loop
     }
    //closes main
     
     
     public static String menu()
      {
     
        String response="";
        System.out.println("Please enter an option");
        System.out.println("*********************************");
        System.out.println("A  Add a DVD                                *");
        System.out.println("T   Search by Title                         *");
        System.out.println("L   Search by length                         *");
        System.out.println("Q   Quit                                 *'");
        System.out.println("********************************");
     
         return response;
      }
     
     public static int addDVD(String titles[], int length[], int numDVDs)
      {
       int numDVDs = numDVDs;
       String titleMovie = "";
       int lengthMovie = 0;
       int entry = 0;
       if(numDVDs == 128)
       {
        return 0;
       }
       else
       {
        System.out.println("Enter title");q
        titleMovie = in.nextLine();
        System.out.println("Enter length");
        lengthMovie = in.nextLine();
        titles[numDVDs] = titleMovie;
        length[numDVDs] = lengthMovie;
        entry++;
        return entry;
       }
     
      }
     
       public static void searchByTitle(String titles[],int length[], int numDVDs)
       {
        System.out.println("Please enter DVD title (post * allowed)  :");
        String titleSearch = in.nextLine();
        // search function
       for(int i=0; i<numDVDs; i++)
            {
             if(titleSearch == titles[i])
             {
              System.out.println("Title  :"+        titles[i]+      "  Length  :" + length[i]);
             }
             else if(title[i].startsWith(titleSearch))
             {
               System.out.println("Titles//////////////////////////Lengths");
               System.out.println("Title   :" + titles[i] + "  Length  :" + length[i]);
             }
             else
             {
               System.out.println("Movie not found");
             }
     
             return;
            }
      }
     
     
     
        public static void searchByLength(String titles[],int length[], int numDVDs)
        {
     
          int lengthSearch =0;
          System.out.println("Enter length for search");
          lengthSearch = in.nextLine();
     
          char option = lengthSearch.charAt(0);
          int length = Integer.parseInt(lengthSearch.substring(1));
          System.out.println("Titles/////////////////Length");
          System.out.println("*****************************");
                            for (int i = 0; i < numDVDs; i++)
                            {
                                 if (option == '=')
                                 {
                                   if(lengthSearch == length[i])
                                   {
                                    System.out.println(titles[i] + "\t" + length[i]);
                                   }
                                 }
                                 else if (option == '<')
                                 {
                                   if(lengthSearch<length[i])
                                   {
                                      System.out.println(title[i] + "\t" + length[i]);
                                   }
                                 }
                                 else if (option == '>')
                                 {
                                   if(lengthSearch<length[i])
                                   {
                                     System.out.println(titles[i] + "\t" + length[i]);
                                   }
                                   else
                                   {
                                      System.out.println("Movie not found");
                                   }
                                       return;
                                 }
                        }
    }


  2. #2
    Junior Member
    Join Date
    May 2011
    Posts
    5
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Compile Error, tried everything please help

    I'd suggest that you wrap your code in between code tags, so it preserves indentation and receives syntax highlighting. I think more people (including myself) will give a shot at reading it if you do so.

    Meanwhile, I suggest not using "Final" to name your class, because of this.

  3. The Following User Says Thank You to gdjs For This Useful Post:

    JavaPF (May 17th, 2011)

  4. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: Compile Error, tried everything please help

    I have added highlight tags for you this time. Please see my signature for the next time you post.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

Similar Threads

  1. Cannot get to compile
    By Goff256 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: April 19th, 2011, 02:09 PM
  2. What's wrong. Compile Ok but error when execute.
    By hantuapi in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 1st, 2011, 06:33 AM
  3. [SOLVED] I CANT COMPILE
    By savvas in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 31st, 2011, 12:34 PM
  4. [SOLVED] Picture won't go with the .jar (Wrong code or compile error?)
    By Fermen in forum Object Oriented Programming
    Replies: 3
    Last Post: March 15th, 2011, 06:22 PM
  5. *why won't this compile?*
    By dcshoecousa in forum What's Wrong With My Code?
    Replies: 6
    Last Post: November 2nd, 2010, 08:18 PM