CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Jul 2010
    Posts
    9

    Trouble with code

    I have attached my assignment. For some reason, my code isn't working properly. I've looked through it, but I can't seem to find the error. If anyone can help me, I would greatly appreciate it.
    Here is my code:
    import java.util.*;

    public class Project_11_1 {
    public static void main(String[] args) {
    System.out.println("Welcome to the Movie List Application");
    System.out.println();
    System.out.println("There are 100 movie in the list");
    String choice = "y";
    Scanner sc = new Scanner(System.in);

    ArrayList<String> animated = new ArrayList<String>();
    animated.add("One Piece");
    animated.add("Bleach");
    animated.add("Naruto");
    animated.add("HellSing");
    animated.add("Final Fantasy 7 Advent Child");


    ArrayList<String>drama = new ArrayList<String>();
    drama.add("Vertigo");
    drama.add("The GodFather");
    drama.add("Touch of Evil");
    drama.add("21 day");
    drama.add("The Searcher");

    ArrayList<String> horror = new ArrayList<String>();
    drama.add("IT");
    drama.add("Alien");
    drama.add("Resident Evil");
    drama.add("Freddy");
    drama.add("Jason");

    ArrayList<String> scifi = new ArrayList<String>();
    scifi.add("Star War");
    scifi.add("Star Trek");
    scifi.add("Stargate");
    scifi.add("Merlin");
    scifi.add("ET");

    while(choice.equalsIgnoreCase("y"))
    {
    System.out.print("What category are you interested in?");
    String movielist = sc.nextLine();
    if (movielist == "animated")
    {
    System.out.println(animated);
    }
    else if (movielist == "drama")
    {
    System.out.println(drama);
    }
    else if (movielist == "horror")
    {
    System.out.println(horror);
    }
    else if (movielist == "scifi")
    {
    System.out.println(scifi);
    }

    System.out.print("Continue? y/n): ");
    choice = sc.next();
    }

    }
    }
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured