Solution to
Write a program that reads in a sentence of up to 100 characters and outputs the sentence with spacing corrected and with letters corrected for capitalization. In other words, in the output sentence, all strings of two or more blanks should be compressed to a single blank. The sentence should start with an uppercase letter but should contain no other uppercase letters.
Do not worry about proper names; if their first letters are changed to lowercase, that is acceptable. Treat a line break as if it were a blank, in the sense that a line break and any number of blanks are compressed to a single blank. Assume that the sentence ends with a period and contains no other periods. For example, the input
the Answer to life, the Universe, and everything IS 42. |
should produce the following output:
The answer to life, the universe, and everything is 42. |
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with Python (3rd Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Python (4th Edition)
Concepts Of Programming Languages
Computer Science: An Overview (12th Edition)
Starting Out With Visual Basic (7th Edition)
- Create a function that takes a string of words and returns the word with the highest score. Each letter of the word gets points according to its position in the alphabet: a = 1, b = 2, C = 3, etc. Examples wordRank ("A quick brown fox.") → "brown" wordRank ("Nancy is very pretty.") "pretty" wordRank ("Come back tomorrow, man!") → "tomorrow" wordRank ("Wednesday is hump day.") "Wednesday" Solution in JS 10arrow_forwardLinux !#bin/bash NOT JAVA OR C++. I NEED LINUX SCRIPT Word Separator 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_forwardPythonarrow_forward
- Try to do asap And do not copy from other sources Write your own code with necessary comments.arrow_forwardwrite code in js Searching Challenge Have the function SearchingChallenge (str) take the str parameter being passed, which will contain only alphabetic characters and spaces, and return the first non-repeating character. For example: if str is "agettkgaeee" then your program should return k. The string will always contain at | least one character and there will always be at least one non-repeating character. Examples Input: "abcdef" Output: a Input: "hello world hi hey" Output: warrow_forwardWrite a program continuously asks the user to enter a sentence until they type "-999". It should call FUNCTIONS to do the following: Collect the uppercase, lowercase, whitespace, digits and punctuation characters that are contained in the sentence WITHOUT DUPLICATES Output: Be sure to LABEL and PRINT the following: • uppercase letters (sorted A-Z) WITHOUT DUPLICATES • lowercase letters (sorted A-Z) WITHOUT DUPLICATES digits (sorted from HIGHEST to LOWEST) WITHOUT DUPLICATES punctuation whitespace WITHOUT DUPLICATES (note – whitespace includes space, tab, newline)arrow_forward
- A palindrome is a word or phrase that reads the same forward and backward, ignoring blanks and considering uppercase and lowercase versions of the same letter to be equal. For example, the following are palindromes:warts n strawradarAble was I ere I saw Elbaxyzczyx Write a program that will accept a sequence of characters terminated by a period and will decide whether the string—without the period—is a palindrome. You may assume that the input contains only letters and blanks and is at most 80 characters long. Include a loop that allows the user to check additional strings until she or he requests that the program end. Hint: Define a static method called is Palindrome that begins as follows: /** Precondition: The array a contains letters and blanks in positions a[0] through a[used − 1]. Returns true if the string is a palindrome and false otherwise. */ public static boolean is a palindrome(char[] a int used) Your program should read the input characters into an array whose base…arrow_forwardWrite a function that checks whether two words are anagrams. Two words are anagrams if they contain the same letters in any order. For example, “silent” and “listen” are anagrams. The header of the function is as follows: bool isAnagram(const string& s1, const string& s2) Write a test program that prompts the user to enter two strings and checks whether they are anagrams.arrow_forwardC++ Program plsarrow_forward
- please code in python Write a function that receives a string and a number (n) as parameters and returns a new string that contains only every nth letter from the given string. print(everyNth('banana', 2)) # should return aaaprint(everyNth('carrot', 3)) # should return rtprint(everyNth('pear', 1)) # should return peararrow_forwardThe internet enables people to network, join a cause, take a poll, etc. Your program will prompt the user for a description of a poll to be taken and then prompt 5 users for a response of 1-10 (1 being a 'poor' response; 10 being the 'best' response).Your program does not have to validate that the user entered 1-10. We'll do that type of checking later.Your program must use a string data type to store the poll description and a Python list data type to save the integer responses of the 5 user responses.Your output should list all the responses stored in the list, the highest given response, the lowest given response and the average of the 5 responses. See sample input and utput below.Review powerpoint 3, slide 21 for an example if you need one. Sample interactive run of your program: Give a simple description of the poll to be takenRate your understanding of the first 3 zyBook chaptersEnter a 1-103Enter a 1-1010Enter a 1-104Enter a 1-102Enter a 1-105Sample outputRate your understanding…arrow_forwardpython: def shakespeare_position(role, section): """ Question 2 - Regex You are reading a Shakespeare play with your friends (as one frequently does) and are given a role. You want to know what line immediately precedes YOUR first line in a given section so that you are ready to go when it is your turn. Return this line as a string, excluding the character's name. Lines will always begin with the character's name followed by a ':' and end in a "." or a "?" Each line is separated by a single space. THIS MUST BE DONE IN ONE LINE. "" Args: role (str) section (str) Returns: str section_1 = 'Benvolio: By my head, here come the Capulets. Mercutio: By my heel, I care not. ' + 'Tybalt: Gentlemen, good den - a word with one of you. Mercutio: And but one word with one of us?' >>> shakespeare_position('Tybalt', section_1) 'By my heel, I care not.' >>> shakespeare_position('Mercutio', section_1) 'By my head, here…arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,