Write a
See an adviser, talk to him, and listen to him.
should produce the following suggested changed version of the sentence:
See an adviser, talk to her or him, and listen to her or him.
Be sure to preserve uppercase letters for the first word of the sentence. The pronoun “his” can be replaced by “her (s)”; your program need not decide between “her” and “hers”. Allow the user to repeat this for more sentences until the user says she or he is done.
This will be a long program that requires a good deal of patience. Your program should not replace the string “he” when it occurs inside another word, such as “here” A word is any string consisting of the letters of the alphabet and delimited at each end by a blank, the end of the line, or any other character that is not a letter. Allow your sentences to be up to 100 characters long.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Problem Solving with C++ (9th Edition)
Additional Engineering Textbook Solutions
Experiencing MIS
Database Concepts (7th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Using MIS (10th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
- 3. Write a program that transforms numbers 1, 2, 3,..., 12 into the corresponding month names January, February, March, ..., December. Hint: Make a very long string "January February March ...", in which you add spaces such that each month name has the same length. Then use substring to extract the month you want.arrow_forwardA very known application in natural language processing is to extract information from a given text. In this lab, you will be able to extract some emotions (Sad and Happy) from a given string and calculate the score of each emotion. You will be given below the words that express sadness, anger, and happiness. For each word, you will be given weight as well, so that when you are calculating for example the score for sadness in the text (string), you can use this formula:arrow_forwardWrite a program which takes a string from the user and replaces all occurrences of ‘b’ with ‘$’.arrow_forward
- Write a program that gets a string from the user and maps the capital letters into small letters, and maps the small letters into capital letters. Namely, 'A' should be changed to 'a'; 'B' should be changed to 'b'; ... 'Z' should be changed to 'z'. Similarly, 'a' should be changed to 'A'; 'b' should be changed to 'B'; etc... Your program should also change the digits into next odd number. Namely, '0' should be changed to '1'; '1' should be leaved as '1'; '2' should be changed to '3'; ... '9' should be leaved as '9'. Your program should print the final form of the altered string. Example: If the user enters: My salary is 1000 TL. The output should be: mY SALARY IS 1111 tl.arrow_forwardWe want to create a program that reads a string and removes from it the characters between two marker characters. For example for the input text: (to buy) We need to buy (i) milk, (ii) eggs, (iii) flour, and (iv) sugar. And using "(" and ")" as the starting and ending markers, the program should output: We need to buy milk, eggs, flour, and sugar. Notice that the number of characters between the markers, and the number of markers present in the string may vary. We will assume that if a starting marker appears in the input text, its corresponding ending marker is also present in the string. Approach: The idea is to copy characters from the input text to an output string variable as long as we have not found the starting marker. From that point on, we ignore the characters in the input text until we find the ending marker. Once we find the ending marker, we resume copying characters to the output string variable, and the process repeats. Drag into the placeholders below the appropriate…arrow_forwardWrite a program which concatenates two strings "I LOVE" and "YOU.", checks for presence of the character "." replaces it with "!", and prints out the final string.arrow_forward
- Write a program that accepts as input a sentence in which all of the words are run together but the first character of each word is uppercase. Convert the sentence to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example the string “StopAndSmellTheRoses.” would be converted to “Stop and smell the roses.”arrow_forwardQ49. Write a program which replace all the words "man" with "woman". Sample Text: That is a strong man.arrow_forwardWrite a python program that takes a string parameter called sentence as the input parameter. This parameter may contain any number of words (one or more letters separated by spaces) and the following three punctuation marks '!' ';' '.' . For example, sentence = "here are some words." or another_sentence = "wow!" Your function must extract each word from the sentence, remove the punctuation marks if there is any, and make the first and the last letters of that word uppercase. For example, "here" will be "HerE", "some" will be "SomE", "wow" will be "WoW" etc. Finally, your function must return a dictionary, where keys of this dictionary are the words of the sentence capitalized as above. For each key (i.e., word) the value should be the length of that word. You are not allowed to use the built-in string.title() method or any negative indexing. You may use any other string methods in your solution. Sample outputs: >>> d = cap_ends("here are some words.") >>>…arrow_forward
- make a program, that has a function that takes in a string argument and prints a sentence indicating the shortest word in that string. If there is more than one word print only the first. Your print statement should read: “The shortest word is x” Where x = the shortest word. The word should be all uppercase.arrow_forwardWrite a c++ program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows: 1 A B C D 2 A B C D 3 A B C D 4 A B C D 5 A B C D 6 A B C D 7 A B C D The program should display the seat pattern, with an 'X' marking the seats already assigned. For example, after seats 1A, 2B, and 4C are taken, the display should look like this: 1 X B C D 2 A X C D 3 A B C D 4 A B X D 5 A B C D 6 A B C D 7 A B C D After displaying the seats available, the program prompts for the seat desired, the user types in a seat, and then the display of available seats is updated. This continues until all seats are filled or until the user signals that the program should end. If the user types in a seat that is already assigned, the program should say that that seat is occupied and ask…arrow_forwardRead a 3-character string from input into variable inString. Declare a Boolean variable allAlphas and assign allAlphas with true if inString only contains alphabetic characters. Otherwise, assign allAlphas with false. Ex: If the input is mgg, then allAlphas is assigned with true, so the output is: String is valid Ex: If the input is ^zc, then allAlphas is assigned with false, so the output is: String is not valid Note: Use getline(cin, inString) to read the entire line from input into inString. #include <iostream>#include <string>#include <cctype>using namespace std; int main() { string inString; /* Your code goes here */ if (allAlphas) { cout << "String is valid" << endl; } else { cout << "String is not valid" << endl; } return 0;}arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning