Questions
Program Zeus:    Complete the Count Vowels program (Count Vowels.cpp template provided at the end) to include two...

Program Zeus:    Complete the Count Vowels program (Count Vowels.cpp template provided at the end) to include two user defined functions (which you will write!). Code lenguage is C++

bool isVowel (char c)       // returns true if c is a vowel and false otherwise

int countVowels (string s) // returns the number of vowels in s.

You can access each character of s by using s.at(i) where i ranges from 0 to s.length()-1.

countVowels () should call isVowel (s.at(i)) to check if character i is a vowel.

Run the program once with the following inputs. For full credit, your output should be the same as the output below.

Please enter a word or type "quit" to exit: apple

apple has 2 vowels.

Please enter a word or type "quit" to exit: twang

twang has 1 vowel.

Please enter a word or type "quit" to exit: xyz

xyz has 0 vowels.

Please enter a word or type "quit" to exit: aeiou

aeiou has 5 vowels.

Please enter a word or type "quit" to exit: antidisestablishmentarianism

antidisestablishmentarianism has 11 vowels.

Please enter a word or type "quit" to exit: quit

Goodbye!

Template for Program:

#include<iostream>

#include<iomanip>

#include<fstream>

using namespace std;

bool isVowel(char);

int countVowels(string); .

int main ( )

{

string word;

int numVowels;cout << "Please enter a word or type \"quit\" to exit: ";

cin >> word;

while ()

{

cout << "Please enter a word or type \"quit\" to exit: ";

cin >> word;

}

cout << "Goodbye!" << endl;

return 0;

}

// This function returns the number of vowels in s.

// This function will call isVowel.

int countVowels(string s)

{

}

// This function returns true if c is a vowel and false otherwise

bool isVowel(char c)

{

}

In: Computer Science

a) Given a variable word that has been assigned a string value,write a string expression...

a) Given a variable word that has been assigned a string value, write a string expression that parenthesizes the value of word. So, if word contains "sadly", the value of the expression would be the string "(sadly)"

b) Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Write a statement that prints the value of price in the form "X dollars and Y cents" on a line by itself. So, if the value of price was 4321, your code would print "43 dollars and 21 cents". If the value was 501 it would print "5 dollars and 1 cents". If the value was 99 your code would print "0 dollars and 99 cents".

c) Assume that word is a String variable. Write a statement to display the message "Today's Word-Of-The-Day is: " followed by the value of word on a line by itself on standard output.

In: Computer Science

You can turn a word into pig-Latin using the following two rules: If the word starts...

You can turn a word into pig-Latin using the following two rules:

  • If the word starts with a consonant, move that letter to the end and append 'ay'. For example, 'happy' becomes 'appyhay' and 'pencil' becomes 'encilpay'.
  • If the word starts with a vowel, simply append 'way' to the end of the word. For example, 'enter' becomes 'enterway' and 'other' becomes 'otherway'. For our purposes, there are 5 vowels: a, e, i, o, u (we consider y as a consonant).

Write a function pig() that takes a word (i.e., a string) as input and returns its pig-Latin form. Your function should still work if the input word contains upper case characters. Your output should always be lower case.

For example, if you enter

pig('happy')

The output should be

'appyhay'

If you enter

pig('Enter')

The output should be

'enterway'

In: Computer Science

If all permutations of the letters of the word "BEFORE" are arranged in the order as...

If all permutations of the letters of the word "BEFORE" are arranged in the order as in a dictionary. What is the 32 word?

In: Statistics and Probability

The syntax of a language is quite simple. The alphabet of the language is {a, b,...

The syntax of a language is quite simple. The alphabet of the language is {a, b, d, #} where # stands for a space. The grammar is
<sentence> → <word> | <sentence> # <word>
<word> → <syllable> | <syllable> <word> <syllable>
<syllable> → <plosive> | <plosive> <stop> | a <plosive> | a <stop>
<plosive> → <stop> a
<stop> → b | d

Which of the following speakers is an imposter? An impostor does not follow the rules of the language.
a: ba#ababadada#bad#dabbada Chimp:

b: abdabaadab#ada
c: Baboon: dad#ad#abaadad#badadbaad

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

Please use this code to get started:

#!/usr/bin/env python3

import sys

def main():

if len(sys.argv) < 2:

print("Provide an input file. Exiting");

exit(1)

wh = WordHistogram( )

with open(sys.argv[1], "r") as fh:

for word in word_iterator(fh):

wh.insert(word)

print(wh.report( ))

if __name__ == '__main__':

main()

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

Using the following words: Honor, Fear, Excitement, Commitment, Water, Food, Need. Imagine you had to write...

Using the following words: Honor, Fear, Excitement, Commitment, Water, Food, Need.

Imagine you had to write an essay for three hours on your selected topic: Diverge: Pick a word from the list above. Breakdown your selected word into its various component parts in order to gain insight into the various ways/ideas you have for the word.

Brainstorm as many different ideas as you can. List 3 of your ideas Converge: Pick the same word. Think of a predetermined goal for that word. Fully describe your goal/idea and develop a plan for your goal. Submit a brief outline (only 1/2 to 1 page outline)

In: Nursing

Design and write a python program that reads a file of text and stores each unique...

Design and write a python program that reads a file of text and stores each unique word in some node of binary search tree while maintaining a count of the number appearance of that word. The word is stored only one time; if it appears more than once, the count is increased. The program then prints out 1) the number of distinct words stored un the tree, Function name: nword 2) the longest word in the input, function name: longest 3) the most frequent word in the input, function name: mostfreq 4) the first 10 words appearing in reverse sorted order : first10

In all three format Preorder Postorder Inorder

In: Computer Science

Java Question I have a Queue containing String type taking in a text file with an...

Java Question

I have a Queue containing String type taking in a text file with an iterator.

I need to use ArrayList and HashMap for freqHowMany to get a frequency table in descending order by the highest frequency words in the text. Any help would be much appreciated and thanks!

final Iterator input = new Scanner(System.in).useDelimiter("(?U)[^\\p{Alpha}0-9']+");
        final Queue queueFinal = new CircularFifoQueue<>(wordsLast);

        while (input.hasNext()) {
            final String queueWord = input.next();
            if (queueWord.length() > minimumLength) {
                queueFinal.add(queueWord); // the oldest item automatically gets evicted
            }

            System.out.println(queueFinal);
        }
    }
}

EXAMPLE:

Your program prints an updated word cloud for each sufficiently long word read from the standard input.

The program takes up to three positive command-line arguments:

  • freqHowMany indicates the size of the word cloud, i.e., the number of words in descending order of frequency to be shown
  • wordMinLength indicates the minimum length of a word to be considered; shorter words are ignored
  • wordLastNwords indicates the size of a moving window of n most recent words of sufficient length for which to update the word cloud

Your program then reads a continuous stream of words, separated by whitespace or other non-word characters, from the standard input. (A word can have letters, numbers, or single quotes.) For each word read, your program prints to standard output, on a single line, a textual representation of the word cloud of the form

The idea is to connect this tool to a streaming data source, such as Twitter, or speech-to-text from a 24-hour news channel, and be able to tell from the word cloud in real time what the current "hot" topics are.

THANKS!

In: Computer Science

Practice question: Note: Demand is stated word for word like that on the practice question Estimated...

Practice question:

Note: Demand is stated word for word like that on the practice question

Estimated consumer demand

Tourists’ demand in the market is estimated to be, QT (P) = 1500 − P

Locals’ demand in the market is estimated to be, QL(P) = 4000 − 4P

-Where P represents the price of a ticket in dollars. It is easy to identify locals, who can present proof-of-address to qualify for cheaper tickets. There is no danger of re-sale between groups. It is estimated that it will cost the tourism operator $20 to make each ticket available, and that there will be no fixed costs. Apart from the annual Ecological Tourism Licence fee (E).

-Show working out

A) Derive the combined demand function for the market.

B) Using the information provided in the scenario, derive the tourism operator’s total cost function. Exclude the cost of the annual licence fee.

C) Assume that the profit-maximising price is above the “choke-price” for locals. Find the profit-maximising quantity and price (Q and P). Is this price consistent with the assumption?

D) Assume that the profit-maximising price is below the “choke-price” for locals. Find the profit-maximising quantity and price (Q and P). Is this price consistent with the assumption?

E) What is the level of producer surplus under uniform pricing?

F) How many tickets will be available to locals, and what is the level of local consumer surplus (CSL)?

G) How many tickets will be available to tourists, and what is the level of tourist consumer surplus (CST )?

H) What is the profit-maximising quantity and price for the local market (QL and PL)? What is the level of consumer surplus in the local market (CSL)?

I) What is the level of consumer surplus in the tourist market under price discrimination (CST )? Clearly reference any results or calculations from previous steps.

J) What is the level of producer surplus under price discrimination?

In: Economics