i cant find out how to solve this program error:
it says break cannot be used outside of loop or switch.. but still...
thanks for your time.
it says break cannot be used outside of loop or switch.. but still...
Code:
import java.util.*;
public class Store {
public static void main (String[] args){
Scanner console = new Scanner(System.in);
String movieTitle, status, userIn;
double movieLength;
int i;
int indexRent = 0;
int indexReturn = 0;
DVD dvd[] = new DVD [6];
dvd[0] = new DVD ("Iron Man",3.5,"In");
dvd[1] = new DVD ("Death Note",2.5,"In");
dvd[2] = new DVD ("Shrek",2,"In");
dvd[3] = new DVD ("Transformer",3.25,"In");
dvd[4] = new DVD ("The Eye",3,"In");
dvd[5] = new DVD ("Fantastic 4",4,"In");
System.out.println("ENTER COMMAND:");
System.out.println("A) Renting DVD(s)");
System.out.println("B) Returning DVD(s)");
System.out.println("C) All DVD informations");
System.out.println("D) Exit program");
System.out.println("Please enter your choice: ");
userIn = console.nextLine();
if (userIn.compareTo("A") == 0 || userIn.compareTo("a") == 0) {
System.out.println("Enter DVD title: ");
String movieTitleReturn = console.nextLine();
for(i=0; i<dvd.length; i++)
{
if(movieTitleReturn.equals(dvd[i].getMovieTitle()));
indexRent = i;
break;
}
if(indexRent == i)
{
dvd[indexRent].dvdRent();
}
else
{
System.out.println("Invalid input - back to main menu");
}
}
else if (userIn.compareTo("b") == 0 || userIn.compareTo ("B") == 0) {
System.out.println("Enter DVD title: ");
String movieTitleReturn = console.nextLine();
for(i=0; i<dvd.length; i++)
{
if(movieTitleReturn.equals(dvd[i].getMovieTitle()));
indexReturn = i;
break;
}
if(indexReturn == i)
{
dvd[indexReturn].dvdReturn();
}
else
{
System.out.println("Process cannot be done - wrong movie title");
}
}
else if (userIn.compareTo("c") == 0 || userIn.compareTo ("C") == 0) {
for(i=0; i == dvd.length; i++)
{
dvd[i].printDetails();
}
}
else if (userIn.compareTo("d") == 0 || userIn.compareTo ("D") == 0) {
System.out.println("Exiting program");
break;
}
else
{
System.out.println("Input is invalid");
}
}
}
thanks for your time.