Questions
Q20. Using C++ style string to write a program that reads a sentence as input and...

Q20. Using C++ style string to write a program that reads a sentence as input and converts each word of the sentence following the rule below:

  • For every word in the sentence, the first letter is relocated the end of the word.
  • Then append the string “KPU” to the word.

More requirements:

  • All letters in the output should be uppercase.

More assumptions:

  • The input sentence contains no non-alphabetic letters

Sample Run:

Please enter the original sentence: i LOVE to program
Translated: IKPU OVELKPU OTKPU ROGRAMPKPU

In: Computer Science

Q20. Using C++ style string to write a program that reads a sentence as input and...

Q20. Using C++ style string to write a program that reads a sentence as input and converts each word of the sentence following the rule below:

  • For every word in the sentence, the first letter is relocated the end of the word.
  • Then append the string “KPU” to the word.

More requirements:

  • All letters in the output should be uppercase.

More assumptions:

  • The input sentence contains no non-alphabetic letters

Sample Run:

Please enter the original sentence: i LOVE to program
Translated: IKPU OVELKPU OTKPU ROGRAMPKPU

In: Computer Science

I get an error in my code, here is the prompt and code along with the...

I get an error in my code, here is the prompt and code along with the error.

Write a spell checking program (java) which uses a dictionary of words (input by the user as a string) to find misspelled words in a second string, the test string. Your program should prompt the user for the input string and the dictionary string. A valid dictionary string contains an alphabetized list of words.

Functional requirements:

  1. For each word in the input string, your program should search the dictionary string for the given word. If the word is not in the dictionary, you program should print the message "Unknown word found" to standard output.
  2. After traversing the entire input string, your program should print a message describing the total number of misspelled words in the string.
  3. A dictionary string may contain words in uppercase, lowercase, or a mixture of both. The test string may also combine upper and lower case letters. You program should recognize words regardless of case. So if "dog" is in the dictionary string, the word "dOG" should be recognized as a valid word. Similarly, if "CaT" is in the dictionary string, the word "cat" she be recognized as a valid word.
  4. Within a string, a word is a white-space delimited string of characters. So the last word in "Hello world!" is "world!".

CODE:

dictionary.java

import java.io.*;
import java.util.*;

public class dictionary
{
public static void main(String args[]) throws Exception
{
     
  
   String dString;
   String uString;
  
   Scanner input=new Scanner(System.in);
  
   System.out.println("Enter distionary string :");
  
   dString = input.nextLine();
  
   System.out.println("Enter input string :");
  
   uString = input.nextLine();
  
   String[] dict = dString.split(" ");//split dictionay string and save to array fo string
  
   boolean found = false;
  
   //ieterate over dictionary string array
   for (String a : dict)
   {
       //compare and print message accordingly       
       if((uString.toLowerCase().compareTo(a.toLowerCase())) == 0)
       {
   System.out.println("word found!");
           found = true;
           break;
       }
   }
  
   if(found == false)
   {
       System.out.println("Unknown word found!");
   }
  
  
  
}
}

ERROR:

Main.java:4: error: class dictionary is public, should be declared in a file named dictionary.java
public class dictionary
^
1 error
compiler exit status 1

In: Computer Science

In programming C language, write a program that creates a binary tree of words to be...

In programming C language, write a program that creates a binary tree of words to be used as a spell
checking device for various text files. The list of words will come from a file “words.txt”.
Your program is to read through the “words.txt” file and insert the word on that line into the tree
in lexicographic order (also known as Dictionary order). Words in the file will be separated by
spaces. Once this is done, your program should then prompt the user to enter a text file and
then scan through each word in the file to check spelling.
Your program must be able to insert words into and delete words from the tree. It must also be
able to search the tree for a given string (this is how the spell check is done), and print the tree
in pre order, in order, and post order.


The functions that do this should look as follows:


● void insert(root, s): node x char* -> none
○ inserts a node whose data is s into the tree with root node root
● void delete(root, s): node x char* -> none
○ deletes a node whose data is s from the tree with root node root
● void print_preorder(root): node -> none
○ prints the tree with root node root in pre-order format
● void print_inorder(root): node -> none
○ prints the tree with root node root in in-order format
● void print_postorder(root): node -> none
○ prints the tree with root node root in post-order format
● node search(root, s): node x char* -> node
○ searches a tree with root node root for a node whose data is s, if it is found then
that node is returned, otherwise a NULL node is returned


For the spell-checking portion of the program, there should be a function spellcheck which takes
as arguments a root node for your tree, and a string for a filename. Spellcheck should scan the
file at that location word by word and check if that word is in the tree, ignoring capitalization and
punctuation (apostrophes are not considered to be punctuation). If the word is not found then a
message should be printed to the console indicating that word is not found / misspelled. The
message should indicate the word’s position in the file.


● void spellcheck(root, filename): node x char* -> none
○ Scans a text file (filename) word by word, prints a message to the console if a
word is not found in the tree of correct words.


Sample Input/Output
words.txt: “all work and no play makes a dull boy”
myInput.txt: “All work and no play maks Jack a dull boy.”
Output:
Word “maks” on line 1, word 6 mispelled or not found in dictionary.”
Word “Jack” on line 1, word 7 mispelled or not found in dictionary.”

Again, in programming C language please.

In: Computer Science

In programming C language, write a program that creates a binary tree of words to be...

In programming C language, write a program that creates a binary tree of words to be used as a spell
checking device for various text files. The list of words will come from a file “words.txt”.
Your program is to read through the “words.txt” file and insert the word on that line into the tree
in lexicographic order (also known as Dictionary order). Words in the file will be separated by
spaces. Once this is done, your program should then prompt the user to enter a text file and
then scan through each word in the file to check spelling.
Your program must be able to insert words into and delete words from the tree. It must also be
able to search the tree for a given string (this is how the spell check is done), and print the tree
in pre order, in order, and post order.


The functions that do this should look as follows:


● void insert(root, s): node x char* -> none
○ inserts a node whose data is s into the tree with root node root
● void delete(root, s): node x char* -> none
○ deletes a node whose data is s from the tree with root node root
● void print_preorder(root): node -> none
○ prints the tree with root node root in pre-order format
● void print_inorder(root): node -> none
○ prints the tree with root node root in in-order format
● void print_postorder(root): node -> none
○ prints the tree with root node root in post-order format
● node search(root, s): node x char* -> node
○ searches a tree with root node root for a node whose data is s, if it is found then
that node is returned, otherwise a NULL node is returned


For the spell-checking portion of the program, there should be a function spellcheck which takes
as arguments a root node for your tree, and a string for a filename. Spellcheck should scan the
file at that location word by word and check if that word is in the tree, ignoring capitalization and
punctuation (apostrophes are not considered to be punctuation). If the word is not found then a
message should be printed to the console indicating that word is not found / misspelled. The
message should indicate the word’s position in the file.


● void spellcheck(root, filename): node x char* -> none
○ Scans a text file (filename) word by word, prints a message to the console if a
word is not found in the tree of correct words.


Sample Input/Output
words.txt: “all work and no play makes a dull boy”
myInput.txt: “All work and no play maks Jack a dull boy.”
Output:
Word “maks” on line 1, word 6 mispelled or not found in dictionary.”
Word “Jack” on line 1, word 7 mispelled or not found in dictionary.”

Again, in programming C language please.

In: Computer Science

Please complete in Python and neatly explain and format code. Use snake case style when defining...

Please complete in Python and neatly explain and format code. Use snake case style when defining variables. Write a program named wordhistogram.py which takes one file as an argument. The file is an plain text file(make your own) which shall be analyzed by the program. Upon completing the analysis, the program shall output a report detailing the shortest word(s), the longest word(s), the most frequently used word(s), and a histogram of all the words used in the input file.

If there is a tie, then all words that are of the same length for that classification (longest, shortest, most frequent) are displayed as part of that class.

A word histogram shows an approximate representation of the distribution of words used in the input file. An example text, The_Jungle_Upton_Sinclair.txt, is provided as a starting point for analyzing natural language. Draw your histogram by listing the word first and then print up to 65 * characters to represent the frequency of the word.

Since there is limited space on a terminal, ensure that your histogram does not wrap along the right edge of the terminal. Assume that the width of the histogram can not be wider than 65 characters. In calculating your histogram, map the highest frequency to 65 characters. For example, if the text has a word that appears 2000 times and it is the most frequently used word, then divide 2000 by 65 to approximate that each * character represents 30 occurrences of the word in question in the text. Thus if a word should appear less than 30 times, it receives zero * characters, a word that appeared 125 time would receive 4 * characters (0-30, 31-60, 61-90, 91-120, 120-150).

Print the order of the histogram from most frequent to least frequent.

The program must have a class named WordHistogram. This class must be the data structure that keeps track of the words that appear in the input text file and can return the histogram as a single string. The main function is responsible for opening and reading the the input text file.

Make sure your WordHistogram class has data members that are correctly named (use the underscore character!), has an initializer, and any necessary methods and data members.

In your main, use the given function to read from the filehandle.

def word_iterator(file_handle):
""" This iterates through all the words of a given file handle. """
  for line in file_handle:
    for word in line.split():
      yield word

DO NOT COMPUTE OR STORE THE HISTOGRAM OUTSIDE OF AN OBJECT named WordHistogram

Example Output

$ ./wordhistogram.py Candide_Voltaire.txt
Word Histogram Report
the (2179) ******************************************************************
of (1233) *************************************
to (1130) **********************************
and (1127) **********************************
a (863) **************************
in (623) ******************
i (446) *************
was (434) *************
that (414) ************
he (410) ************
with (395) ***********
is (348) **********
his (333) **********
you (317) *********
said (302) *********
not (276) ********
...
$

In: Computer Science

Name the element with atomic number (Z) = 15 and atomic mass number = 31, Use...

Name the element with atomic number (Z) = 15 and atomic mass number = 31, Use the symbol, not the word.

How many electrons does the neutral atom of this element have? Use a number, not a word.

How many neutrons does the neutral atom of this element have? Use a number, not a word.

In: Chemistry

What are some of the features about Word that you find interesting? What are some of...

What are some of the features about Word that you find interesting?

What are some of the features that you find frustrating?

How could Microsoft Word help you in your career?

Are there any other word processing tools that you use in your daily life (e.g. Google Docs)?

In: Computer Science

Language is Java Design and write a Java console program to estimate the number of syllables...

Language is Java

Design and write a Java console program to estimate the number of syllables in an English word. Assume that the number of syllables is determined by vowels as follows. Each sequence of adjacent vowels (a, e, i, o, u, or y), except for a terminal e, is a syllable. However, the minimum number of syllables in an English word is one.

The program should prompt for a word and respond with the estimated number of syllables in that word. A run of the program should look exactly like this:

        Enter a word: hairy
        "hairy" has 2 syllables

Cannot use an array!!! Do NOT use continue or break!

My program accepts information fine, I'm just having trouble with the loop that counts how many syllables are in the string.

In: Computer Science

write a python program that reads a sentence and identifies a word from an existing glossary...

write a python program that reads a sentence and identifies a word from an existing glossary and states the meaning of the word

In: Computer Science