I have been stuck on this problem for a while. I can't figure out why it is skipping over the last part of my program where it starts double totalMoviePrice. Here is what I have:

import java.util.Scanner;
public class OnDemandMovieHits_AngelaBrasley 
{
    public static void main(String[]args)
    {
        String[] movieName = new String[7];

        Scanner input = new Scanner (System.in);

        System.out.println("Enter the name of 7 movies that can be purchased");
        Integer index;
        for (index = 0; index < movieName.length; index++)
        {
            System.out.println("\nEnter movie " + (index +1));
            movieName[index] = input.nextLine();
            System.out.println("\nThe name of the movie " + (index+ 1) + " is: " + movieName[index]);
        }
        double[]moviePrice = new double [7];
        System.out.println("Enter the cost of each movie");

        double digit;
        index = 0;
        for (digit = 0; digit < moviePrice.length; digit++)
        {
            System.out.println(" The cost for the movie: " + movieName[index]+ " is: ");
            moviePrice[(int) digit] = input.nextDouble();
            index++;
        }
        System.out.println("movie name    ticket price");
        Integer count;
        for (count = 0; count < movieName.length; count++)
        {
            System.out.println(movieName[count] + "                 $" + moviePrice[count]);
        }
        String movie;
        System.out.println("Select the movie you want to see: ");
        movie = input.next();

        double totalMoviePrice;
        if (movie == movieName[0])
        {
        index = 0;
        System.out.println("How many days do you want the movie" + "" + movieName[0]);
        Integer days;
        days = input.nextInt();
        totalMoviePrice = moviePrice[0] * days;
        System.out.println("The price to see " + movieName[0] + " is " + totalMoviePrice);
        }

        else
        {
            System.out.println("You entered the wrong movie name");
        }
    }
}

Here is my assignment:
Write a program in a class OnDemandMovieHits that computes the cost of each movie sold On Demand. There are 7 movies. You may come up with the list of the 7 movies. Also, come up with a unique cost for each movie per day. The higher the popularity, the more expensive the movie needs to be. Create an array of strings that holds the names of the movies. Create another array that holds the cost of each corresponding movie. Your program should allow the user to select from a menu list of movies and the number of days the customer wants to keep the movie available to them. Locate the movie in the name array and use that index to find the cost per day in the cost array. Compute and print the total cost of sale.

Hi, You need to watch your indexing with arrays. At one point you index with a double type and at other points you indexed movies with just a 0. I've clean up your code a bit and made a couple alterations and I think it works the way you need it to now. Please though, print out both codes and look at the differences. Not to say what I gave you is perfect but I don't write a lot of Java.

import java.util.Scanner;
/**
 *
 * @author Stuugie
 * All work already done, helped with errors.
 */
public class OnDemandMovieHits1_AngelaBransley 
{
    public static void main(String[]args)
    {
        String[] movieName = new String[7];
        Scanner input = new Scanner (System.in);
        System.out.println("Enter the name of 7 movies that can be purchased");

        for (int i = 0; i < movieName.length; i++)
        {
            System.out.println("\nEnter movie " + (i+1));
            movieName[i] = input.nextLine();
            System.out.println("\nThe name of the movie " + (i+ 1) + " is: " + movieName[i]);
        }
        double[]moviePrice = new double [7];
        System.out.println("Enter the cost of each movie");
        //double digit[7];


        for (int i = 0; i < moviePrice.length; i++)
        {
            System.out.println(" The cost for the movie: " + movieName[i]+ " is: ");
            moviePrice[i] = input.nextDouble();

        }
        System.out.println("movie name    ticket price");

        for (int i = 0; i < movieName.length; i++)
        {
            System.out.println(movieName[i] + "                 $" + moviePrice[i]);
        }
        String movie;
        System.out.println("Select the movie you want to see: ");
        movie = input.next();
        double totalMoviePrice;

        boolean pickCheck=false;
        boolean checked=false;
        for (int i=0;i<movieName.length;i++)
        {
            if (movie.equals(movieName[i]))
            {
                pickCheck=true;
                if (pickCheck=true)
                {
                    checked = true;
                }

                System.out.println("How many days do you want the movie" + "" + movieName[i]);
                Integer days;
                days = input.nextInt();
                totalMoviePrice = moviePrice[i] * days;
                System.out.println("The price to see " + movieName[i] + " is " + totalMoviePrice);
                //System.out.println(movieName[index]);
            }

        }
        if (checked = false){
            System.out.println("You entered teh wrong movie name");
        }
    }
}

Thank you so much! It worked..Yay.

Yes it does but you should really think about looking at why it works compared to your code that you provided. It has been brought to my attention, and rightly so, that I may have in fact helped you cheat on an assignment but I really hope not. Cheating on an assignment won't help you at exam time. That aside, you really need to understand your loops and indexing better. Perhaps another read of the chapter from your text book would be a good idea.

Yes. I have been in my book all day and still currently reading through the contents. I have reviewed over what information you gave me and what information that I typed in. I'm not just trying to pass the class I actually want to learn what I am doing and how I got to the answer that I got to. If I don't grasp it now it will not help me in my future programming classes. And I'm just getting started. Thanks for the help.I'm actually using this to study for a final exam. Thank you again! :)

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.