Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 21, Problem 21.3PE
Program Plan Intro

CountKeywords.Java

Program Plan:

  • Include a class named “CountKeywords”.
    • Import “util” package.
    • Import “io” package.
    • Declare the main method.
    • Check if user has inputted any command line argument or not.
      • If the command line argument is empty then print “Usage:Filename” and exit from the system.
      • Create a file inputted by the user from the command line.
      • Check if file exists and print the number of keywords by invoking the CountKeywords() method.
    • Declare a method that returns the number of keywords in a file.
    • Create an array containing all the keywords present in java.
    • Set all the keywords into a new HashSet named “KeywordSet”.
    • Run a loop till the end of file.
      • Exclude the comments, strings and block elements present in the file.
    • Return the number of keywords.
  • Create a new text file “file”.
    • Add words into the text file.

Blurred answer
Students have asked these similar questions
(True/False): When a program’s source code is modified, it must be assembled and linkedagain before it can be executed with the changes
(Class Average: Reading Student Records from a CSV File) Use Python Use the csv module to read the grades.csv file from the previous exercise (exercise 9.3). Display the data in tabular format, including an additional column showing each student’s average to the right of that student’s three exam grades and an additional row showing the class average on each exam below that exam’s column. This is exercise 9.3 # Importing csv moduleimport csv# empty list to store datadata = []columns = ["firstname", "lastname", "grade1", "grade2", "grade3"]filename = "grades.csv"for i in range(3):firstname = input("Enter First Name : ")lastname = input("Enter Last Name : ")grade1 = float(input("Enter Grade 1 : "))grade2 = float(input("Enter Grade 2 : "))grade3 = float(input("Enter Grade 3 : "))data.append([firstname, lastname, grade1, grade2, grade3])print()# write data and columns as csv filewith open(filename, 'w') as csvfile:# creating a csv writer objectcsvwriter = csv.writer(csvfile)# writing the…
(True/False): When a program's source code is changed, it must be reassembled and linked before it can be executed.
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning