Im pretty new to java and I'm having trouble using if else statements. My complier keeps telling me
error: 'else' without 'if' else if (theName.equalsIgnoreCase != name);
It does this for each section of the if else. How do I change my if else statement to compile correctly? Thank you. ^
import java.util.*; //scanner
public class MinilabUsingClasses
{
public static void main (String [] args)
{
Scanner kb = new Scanner(System.in); //creating new instance of scanner
int numTickets; //variable for number of tickets
String name; //variable for name
System.out.print("How many tickets do you have? " ); //ask user for numtickets
numTickets = kb.nextInt();
System.out.print("\nWhat is your name? " ); //ask user for name
name = kb.next();
System.out.println("\n");
for (int i= 0; i <= numTickets; i++) // use for loop to bring in random ticket info
{
Ticket currentTicket = new Ticket(name);
int newSpeed = currentTicket.getSpeed();
if (newSpeed- LIMIT <= 11)
{
System.out.println(currentTicket.toString());
System.out.println ("Fight");
}
else if (newSpeed-LIMIT > 11)
{
System.out.println(currentTicket.toString());
System.out.println("Pay");
}
else if (theName.equalsIgnoreCase == name);
{
System.out.println("Pay");
}
else if (theName.equalsIgnoreCase != name);
{
System.out.println("Fight");
}
else if (cameraID = A);
{
System.out.println ("fight");
}
else if (cameraID + 35);
{
System.out.println("fight");
}
else if (cameraID != 35 );
{
System.out.println ("Pay");
}
}
}
Aucun commentaire:
Enregistrer un commentaire