Questions
(1) Prompt the user for a string that contains two strings separated by a comma. (1...

(1) Prompt the user for a string that contains two strings separated by a comma. (1 pt)

  • Examples of strings that can be accepted:
    • Jill, Allen
    • Jill , Allen
    • Jill,Allen

Ex:

Enter input string:
Jill, Allen


(2) Print an error message if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)

Ex:

Enter input string:
Jill Allen
Error: No comma in string.

Enter input string:
Jill, Allen


(3) Extract the two words from the input string and remove any spaces. Store the strings in two separate variables and output the strings. (2 pts)

Ex:

Enter input string:
Jill, Allen
First word: Jill
Second word: Allen


(4) Using a loop, extend the program to handle multiple lines of input. Continue until the user enters q to quit. (2 pts)

Ex:

Enter input string:
Jill, Allen
First word: Jill
Second word: Allen

Enter input string:
Golden , Monkey
First word: Golden
Second word: Monkey

Enter input string:
Washington,DC
First word: Washington
Second word: DC

Enter input string:
q

_________________________

Given code to work with: main.cpp

#include <iostream>
#include <string>
using namespace std;

int main() {

/* Type your code here. */
  
return 0;
}

thanks.

In: Computer Science

In C Please *Asked before but all previous answers do not work correctly* 10.6 LAB: Warm...

In C Please

*Asked before but all previous answers do not work correctly*

10.6 LAB: Warm up: Parsing strings

(1) Prompt the user for a string that contains two strings separated by a comma. (1 pt)

  • Examples of strings that can be accepted:
    • Jill, Allen
    • Jill , Allen
    • Jill,Allen

Ex:

Enter input string:

Jill, Allen


(2) Report an error if the input string does not contain a comma. Continue to prompt until a valid string is entered. Note: If the input contains a comma, then assume that the input also contains two strings. (2 pts)

Ex:

Enter input string:
Jill Allen
Error: No comma in string.

Enter input string:
Jill, Allen
(3) Extract the two words from the input string and remove any spaces. Store the strings in two separate variables and output the strings. (2 pts)

Ex:

Enter input string:

Jill, Allen

First word: Jill

Second word: Allen


(4) Using a loop, extend the program to handle multiple lines of input. Continue until the user enters q to quit. (2 pts)

Ex:

Enter input string:

Jill, Allen

First word: Jill

Second word: Allen

Enter input string:

Golden , Monkey

First word: Golden

Second word: Monkey

Enter input string:

Washington,DC

First word: Washington

Second word: DC

Enter input string:

q

In: Computer Science

you will be implementing two functions for the LinkedList class. The function that you are implementing...

you will be implementing two functions for the LinkedList class. The function that you are implementing is called reverse and isPalindrome. The isPalindrome function should determine if the linked list is a palindrome or not and the reverse function should reverse the linked list.

When you are finished with the implementation, try to use valgrind to see if there are any other errors or memory leaks to deal with. valgrind ./lab7 or make val

  1. Expected Output

This is an example of what the output should look like. Note that the program must compile without any warnings or memory leaks.

==2353315== Memcheck, a memory error detector

==2353315== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.

==2353315== Using Valgrind-3.16.0 and LibVEX; rerun with -h for copyright info

==2353315== Command: ./lab7

==2353315==

The word: tenet is a palindrome.

The word: LOLO is not a palindrome.

The word: Zendaya is not a palindrome.

The word: kayak is a palindrome.

The word: step on no pets is a palindrome.

The word: I did did I is a palindrome.

The word: CMSC 202 is not a palindrome.

The word: wasitacatisaw is a palindrome.

==2353315==

==2353315== HEAP SUMMARY:

==2353315==     in use at exit: 0 bytes in 0 blocks

==2353315==   total heap usage: 158 allocs, 158 frees, 76,512 bytes allocated

==2353315==

==2353315== All heap blocks were freed -- no leaks are possible

==2353315==

==2353315== For lists of detected and suppressed errors, rerun with: -s

==2353315== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

In: Computer Science

Write a python program using the following requirements: Create a class called Sentence which has a...

Write a python program using the following requirements:

Create a class called Sentence which

  • has a constructor that takes a sentence string as input.
    • The default value for the constructor should be an empty string
    • The sentence must be a private attribute in the class
  • contains the following class methods:
    • get_all_words — Returns all the words in the sentence as a list
    • get_word — Returns only the word at a particular index in the sentence
      • Arguments: index
    • set_word — Changes the word at a given index in sentence to a new word
      • Arguments: index, new_word
      • Does not return anything
    • a str method — Returns the sentence as a string using the built in method

Include a unit test in an if __name__ block to test the class. Use assert to check for errors.

Unit Test Example:

  • Set a sentence variable with a sentence of your choice
  • Instantiate the Sentence object using the variable
  • Test that get_all_words() correctly returns that sentence as a list
  • Test that get_word(#) correctly returns the # word in the sentence
  • Test that replace() actually changes a word in the sentence object
  • Print the sentence before and after the word change using the built in str method

In: Computer Science

do tou agree wjth the argument that globalization constrains the autonomh and capacity of the state?...

do tou agree wjth the argument that globalization constrains the autonomh and capacity of the state? why or why not?
must be 600 words and not word for word from google

In: Economics

This function takes in a string as a parameter and prints the average number of characters...

This function takes in a string as a parameter and prints the average number of characters per word in each sentence in the string. Print the average character count per word for each sentence with 1 decimal precision (see test cases below).

  • Assume a sentence always ends with a period (.) or when the string ends.

  • Assume there is always a blank space character (" ") between each word.

  • Do not count the blank spaces between words or the periods as a character.

    Two example test cases are:

    >>> processString("An example. Dog")
    4.5 3.0
    (Note that the first sentence has 2 words with a total of 9 characters, so 4.5 characters per word on average. The second sentence has 1 word of 3 characters, so 3 characters on average.)

    >>> processString("This is the first sentence. The second sentence starts after the period. Then a final sentence")
    4.4 5.3 4.5

In: Computer Science

Using Python The script is to open a given file. The user is to be asked...

Using Python

  • The script is to open a given file. The user is to be asked what the name of the file is. The script will then open the file for processing and when done, close that file.
  • The script will produce an output file based on the name of the input file. The output file will have the same name as the input file except that it will begin with "Analysis-". This file will be opened and closed by the script.
  • The script is to process the file and calculate the following information and output the information to the file in the order presented here.
  • The script it to count the number of lines, the number of words, and the number of characters in the file and put this information out into the output file with appropriate labels for the reader to know what the numbers are. This information is to be echoed on the screen to the user.
    • You may find it easier to determine the number of words if you remove the punctuation, digits, and other non letter characters other than spaces before trying to count the words. Those items are not considered to be part of a word. Keep that in mind when referencing words in following instructions.
    • Count spaces, digits, punctuation and other non letter characters as characters though
  • The script is produce a list of all unique words in the file and the of times each word appears in the file. This list with frequency counts is to be put in the output file in alphabetical order and one word/frequency pair to a line. The format should be word (frequency count). Be sure there is a space between the word and the beginning parentheses. You will count words that appear only once. Due to the possible length of this list, you are not to echo this list to the screen, only place it in the output file.
  • The script is to produce a list of 2 word pairs found in the file that appear more than once. If a 2 word pair appears only once, it is not to be put into the output file. The format of the line in the output file should be the two word pair followed by the frequency count in parentheses as seen in the previous item involving unique words. This list is put out after the single word list. There is to be a heading to the list to let the user know that the information is changing and a blank line put in before the heading. This information is to be echoed on the screen to the user.
  • The last bit of information the script it to place into the output file is the total number of words, the average length of a word, the number of unique words, the average number of letters in the unique words, and the number of word pairs that have frequencies of 2 or more.   Properly label each item of information output in this section as well as placing a blank line before the section and giving the section a heading. This information is to be echoed on the screen to the user.
    • It is fully conceivable that the average number of letters in a word (length of a word) for the over all document is different than the average number of letters in a word for the unique word list. This is because a word such as "the" might appear multiple times in the file. In the first calculation, each instance of the is counted. In the second calculation, the word "the" is only counted 1 time on the list.
  • The script is to use solid programming practices like comments, self documenting variable names (also known as meaningful variable names) and easy to read and neat code.
  • You are to place a comment block at the very top of the script containing your name, the semester, the due date of the exam, and the instructor's name each on separate lines.

The logic is built to examine the process incoming data for specific items of information. This may need to be done in specific order with multiple processing steps.

You are to run your script of this test data file. Screen shot your interactions with the user for your submission document. Then place your analysis file, your python code file, and your submission document into a single zip file.

Some advice would be since you have the test data file, you can do these calculations by hand and check them against your analysis file to see if your program is working correctly.

In: Computer Science

Vocabulary: write the definition of the following words capital letters and give a synonymous for each...

Vocabulary: write the definition of the following words capital letters and give a synonymous for each word, then use the each word in a sentence. (TIRADE, WIZENED, PULCHRITUDINOUS, DISSEMINATE, CLEAVE)

In: Electrical Engineering

JAVA. A palindrome is a word or a phrase that is the same when read both forward and backward.

java please. 

A palindrome is a word or a phrase that is the same when read both forward and backward. Examples are: "bob," "sees," or "never odd or even" (ignoring spaces). Write a program whose input is a word or phrase, and that outputs whether the input is a palindrome.

Ex: If the input is:

bob

the output is:

bob is a palindrome

Ex: If the input is:

bobby

the output is:

bobby is not a palindrome

Hint: Start by removing spaces. Then check if a string is equivalent to it's reverse.


Hint: Start by just handling single-word input, and submit for grading. Once passing single-word test cases, extend the program to handle phrases. If the input is a phrase, remove or ignore spaces.

In: Other

Suppose that a system uses DMA for data transfer from disk controller to main memory. Further...

Suppose that a system uses DMA for data transfer from disk controller to main memory. Further assume that it takes t1 nsec on average to acquire the bus and t2 nsec to transfer one word over the bus (t1 >> t2). After the CPU has programmed the DMA controller, how long will it take to transfer 1000 words from the disk controller to main memory, if

(a) word-at-a-time mode is used?

(b) burst mode is used?

Assume that commanding the disk controller requires acquiring the bus to send one word and acknowledging a transfer also requires acquiring the bus to send one word.

In: Computer Science