Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Searches an string array yo
- *
- * @author Nitin Armstrong (the one and only)
- * @version 4.20
- */
- import java.io.*;
- import java.util.Scanner;
- public class NitinsCode {
- public static void main(String [] args) {
- ScansADoc();
- String [] stringDoc = new String [ScansADoc()];
- System.out.println("Welcome to the ARK, I am Elytra, ready to guide you");
- System.out.println("Input your word below now");
- compareStrings(stringDoc);
- }
- public static int ScansADoc() {
- int y = 0;
- try {
- Scanner scan = new Scanner(new BufferedReader(new FileReader("words.txt")));
- int size = 0;
- while(scan.hasNext()) {
- size++;
- scan.next();
- }
- String[] words = new String [size];
- scan.close();
- scan = new Scanner(new BufferedReader(new FileReader("words.txt")));
- while(scan.hasNext()) {
- words[y] = scan.next();
- y++;
- }
- String myWord = "Will";
- if (myWord.compareToIgnoreCase(words[10]) < 0) {
- /**
- * This means myWord is less than words[10]
- */
- }
- } catch (Exception e) {
- System.out.println("Valve Anti Cheat has Banned you for" + e.getMessage());
- }
- return (y);
- }
- public static void compareStrings(String [] stringDoc) {
- Scanner scan2 = new Scanner(System.in);
- scan2.next();
- String a = scan2.next();
- String b = stringDoc[stringDoc.length/2];
- for (int x = 0;x < 10; x++ ){
- if (a.compareToIgnoreCase(b) < 0) {
- bPositive(stringDoc);
- }
- else if (a.compareToIgnoreCase(b) > 0) {
- bNegative(stringDoc);
- }
- else if (a.compareToIgnoreCase(b) == 0) {
- System.out.println("The Word you specified is in the array");
- break;
- }
- }
- }
- public static String bPositive(String [] stringDoc) {
- String b = stringDoc[stringDoc.length/2 + 1];
- return(b);
- }
- public static String bNegative(String [] stringDoc) {
- String b = stringDoc[stringDoc.length/2 -1];
- return(b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement