import java.util.Scanner;
public class App {
public static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
boolean Found == false;
int Max = 4;
int Current = 1;
String[] Names = {"Ben", "Thor", "Zoe", "Kate"};
System.out.println("What player are you looking for?");
String playerName = scan.nextLine();
while (Found == false)
{
if (Names[Current].equals(playerName))
{
Found == true;
}
else
{
Current = Current + 1;
}
}
if (Found == true)
{
System.out.println("Yes, they have a top score");
}
else {
System.out.println("No, they do not have a top score");
}
}
}
If i input a value that is not in my array it still outputs "yes they have a top score" when it should output "no they dont have a top score"
here is what i need the code to do;
Write a program for the above algorithm. Test the program by searching for a player named 'Thor'. Test the program by searching for a player named 'Imran'. Save the program in your new Question7 folder/directory.
Aucun commentaire:
Enregistrer un commentaire