(1) Prompt the user for a string that contains two strings separated by a comma. (1 pt)
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 up: Parsing strings
(1) Prompt the user for a string that contains two strings separated by a comma. (1 pt)
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 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
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
Include a unit test in an if __name__ block to test the class. Use assert to check for errors.
Unit Test Example:
In: Computer Science
In: Economics
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 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 word, then use the each word in a sentence. (TIRADE, WIZENED, PULCHRITUDINOUS, DISSEMINATE, CLEAVE)
In: Electrical Engineering
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 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