Preview

Anagram.Java

Satisfactory Essays
Open Document
Open Document
448 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Anagram.Java
import java.io.*; import java.util.*;

public class anagram {

//Creates the arrayList called 'wordList' that is used to store the words from the file. private static ArrayList wordList = new ArrayList(); //Declares an array of String type called 'sigList'. static String[] sigList; //Creates the scanner that is used to read the input file private static Scanner scanner = new Scanner(System.in);

public static void main(String args[]) throws IOException { //Prompts the user for an input file. If the file exists, //it then begins to go through each word in the file. System.out.print("Enter the name of the input file: "); String fileName = scanner.nextLine(); File file = new File(fileName); try { Scanner sc = new Scanner(file); String s; while (sc.hasNext()) { s = sc.next(); //The program must tests the number of character per word. //If a word consist of more than 12 characters, the program ignores it and continues. if (s.length() 50) { System.out.println("there are more than 50 words in the input file"); System.exit(1); }

//Sets the length of 'sigList' as the same size as 'wordList'. sigList = new String[wordList.size()];

// the program treats upper and lower case letters as equivalent and ignore punctuation marks. //However, the program displays word with their original capitalizations and punctuations. ListIterator i = wordList.listIterator(); int n = 0; while (i.hasNext()) { String tempWord = i.next(); String tempWord2 = stripPunc(tempWord.toLowerCase()); createSig(tempWord2, n); n++;

}

//Calls the 'sortBoth' method. sortBoth();

//Goes through each element in 'sigList'

You May Also Find These Documents Helpful

  • Good Essays

    Exercise 1: Review of array-based lists Create a project using the classes in the DocSharing area labeled “User-defined array list." Compile it, run it, and review the code that is given carefully. This code tests the ArrayList class provided in the lecture.…

    • 714 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    For Visual Basic a variable’s name must have a letter as the first character, you cannot use spaces, periods, or other special characters such as !@#. The name cannot exceed 255 characters. The variable should not have a similar name as the functions, statements, and methods, and the name cannot be repeated within the scope. This language is not case sensitive.…

    • 333 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Shian Thorpe English Summary “Does IM Make U Dum?” By Martha Brockenbrough is about the use of abbreviations and grammar. The author says the use of emoticons, facial expressions and punctuation marks are good for having a conversation with your friends it helps you communicate quickly and clearer. She also says when it is not okay to use abbreviations. Like if you are writing something to someone you want to impress like a teacher or boss.…

    • 270 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Uppercase characters are distinct from lowercase characters. Using ALL uppercase letters are primarily used to identify constant variables. Remember that variable names are…

    • 368 Words
    • 2 Pages
    Satisfactory Essays
  • Better Essays

    Program Lovecs.Java

    • 422 Words
    • 2 Pages

    import java.util. Scanner; public class LoveCS { public static void main(String[] args) { Scanner scan=new Scanner(System.in); System.out.println("Enter how many times you wish the message to be printed."); int limit = 0; limit= scan.nextInt(); int sum=0; int count=1; while (count <=limit) { System.out.println(count+" I love Computer Science!!"); sum+=count; count++; } System.out.println("Printed this message " + limit + " times."); System.out.println("The sum of the numbers from 1 to "+limit+" is "+sum); } } import java.util. Scanner; public class PowersOf2 { public static void main(String[]args) { int valuePowersOf2; int nextPowersOf2 =1; int exponent= 0; int count=0; Scanner scan = new Scanner(System.in); System.out.println("Enter A Number.");…

    • 422 Words
    • 2 Pages
    Better Essays
  • Powerful Essays

    Legt2751

    • 1592 Words
    • 6 Pages

    2. The word limit is 2,000 words – whilst we will allow +10%, any words in excess of 2,200 will not be marked (i.e. wasted words).…

    • 1592 Words
    • 6 Pages
    Powerful Essays
  • Good Essays

    You can also prefer a mixture of upper case and lower case letter with numbers…

    • 691 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Paragraph and Arrow Ref

    • 3374 Words
    • 22 Pages

    5. When Word flags a possible spelling or grammar error, it also changes the Spelling and Grammar…

    • 3374 Words
    • 22 Pages
    Good Essays
  • Good Essays

    This standard is demonstrated in students’ final drafts of their papers. Part of the grading criteria is whether or not the students used proper spelling and punctuation in their assignment.…

    • 422 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    This Is a Paper

    • 469 Words
    • 2 Pages

    The program will terminate because it is expecting an integer value and a “Wingding” will cause an error in the program which will cause it to crash.…

    • 469 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    CHAPTER08

    • 2686 Words
    • 19 Pages

    What method is used to copy the contents of a string array or LINQ query into a text file?…

    • 2686 Words
    • 19 Pages
    Powerful Essays
  • Good Essays

    2 points – Capitalization and punctuation errors do not interfere with the readability of the…

    • 771 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Homework 2

    • 1897 Words
    • 8 Pages

    The affect to readability can be positive when it is used in conjunction with a cohesive programming technique. The use of upper case letters to help certain types of identifiers stand out in the code can be highly beneficial.…

    • 1897 Words
    • 8 Pages
    Powerful Essays
  • Satisfactory Essays

    Basic Computer Etiquette

    • 431 Words
    • 2 Pages

    2. According to Kids Domain, you should never type in all capitalized letters just to emphasize a word because people take it as "shouting." When writing content on the web, try your best to use correct grammar and spelling and break up large pieces into paragraphs. If sending documents and email online, try to use a format that any computer can read--other Web browsers may not display unusual fonts properly.…

    • 431 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    3. In BASIC programming language which character is used as a last character with string variable?…

    • 477 Words
    • 2 Pages
    Satisfactory Essays