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.