Write a
I say Hi. |
should produce output similar to the following:
3 words 1 a 1 h 2 i 1 s 1 y |
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with Java: Early Objects (6th Edition)
C How to Program (8th Edition)
Java How To Program (Early Objects)
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
- A program has a string variable fullName that stores a first name, followed by a space, followed by a last name. There are no spaces in either the first or last names. Here are some examples of fullName values: "Anthony Coppola", "Jimmy Carroll", and "Tom DeWire". Consider this code segment that extracts the last name from a fullName variable, and stores it in last Name with no surrounding blanks: int k = fullName.indexOf(" "); //find index of blank String lastName = /* expression */ Which is a correct replacement for /* expression */? II fullName.substring(k + 1); III fullName.substring(k + 1, fullName.length());arrow_forwardjava: Run length coding is a method to represent a string in a more compact manner. Each character that occurs more than 2 times in a row is represented by the character and a number following it. Two examples are: "abba" → "abba""abcccbbbba" → "abc3b4a"Write a function that calculates how many characters the encoded string is shorter than the original.arrow_forwardCreate 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_forward
- ///////Som do it.arrow_forwardDescriptionA researcher is analyzing DNA. A DNA can be represented as a string composed of the characters A, G, C, or T.One day, researchers found a strange DNA, which is Smooth Repeated DNA. The DNA is represented by a string that has infinite length. The string has a repeating pattern, i.e. the DNA string 0 is repeated an infinite number of times. For example, if0 = "????", then = "???????????? . . . ".According to researchers, a DNA is said to be special if it contains substrings . Determine whetheris a substring of . Squad FormatA line containing the two strings 0 and . Output FormatA line that determines whether it is a substring of . Issue “YES” ifis a substring of . Output “NO” otherwise. Example Input and Output Input Example Example Output AGCT GC YES AGCT TA YES AGCT GT No AGCT TAGCTAGCT YES AGGACCTA CTAA YES Explanation ExampleIn the first to fourth test case examples, is worth "???????????? . . . ". The part in bold is one of the…arrow_forwardC LANGUAGEarrow_forward
- Write a program that: Declare the following integer variables: Leftmotor Rightmotor Declare the following character arrays: lilac of size 50. - lea of size 30. Program 9 Repeat the steps below 10 times and then quit the program. Ask the user for a robot command and store it in a character array of size 50. Store the user input in lilac. The user input consist of up to two words inputted as one string. The motors are assigned values according to the string input and the table below. Also the input string could be one word or two words. If the first word is STOP then no further instruction is needed (no second word in the string). If the first word is move then a second word will follow First word Second word Left motor Right motor STOP 0 0 MOVE FORWARD 127 127 MOVE REVERSE -127 -127 MOVE MOVE LEFT RIGHT 64 127 127 64 The user input could be a mix of upper case and lower case letters so you need to change all the input to upper case before comparing with the instruction words.arrow_forward] Write a program that prompts a user to enter a year between 1 and 2499 and prints its century in the format such as 1st, 2nd, 3rd, 4th, etc. Use a switch statement. for what we have done in class so far we have only used #include <iostream> <fstream> <cmath> <string> <iomanip>, so if possible if this can be done using that so I can understand for my next assignment that would be great thanks! Test Run 1:Enter a year between 1 and 2499 -- 19231923 is in the 20th century Test Run 2:Enter a year between 1 and 2499 -- 22022202 is in the 23rd century Test Run 3:Enter a year between 1 and 2499 -- 2630Wrong year!arrow_forwardCode language Java 1, Add a print statement to say “Multiplication Table” and then prompt theuser to enter an integer. Your program should then prints “times table” for thenumbers from 1 to the given integer (inclusive). That is, for input n, you would printa table of n rows (lines) each with n columns, where the cell at row i and columnj contains the value i × j. You do need separate rows, but don’t worry about thecolumns lining up nicely yet. 2. Add a print statement to say “Prime Testing”.Using the integer entered by the user above, print out all the prime numbers between2 and the number squared. E.g., if the user types 12 for the multiplication table part,you should print all the prime numbers that are not larger than 144.All integers are either prime or composite. A prime number is one that has no integerfactors other than itself or one. Examples are 2, 3, 5, 7, 11, 13, . . .. A compositenumber, by contrast, has multiple factors. Examples are 4, 6, 12, 15, 18, 21, . . ..Testing…arrow_forward
- 6. Write a program which reads string and rewrite it in alphabetical order. For example, the word STRING should be written as GINRST. 7. Write a program to replace a particular word by another word in a given string. For example the “PYTHON” should be replaced by “C” in the text “It is good to program in PYTHON language”. 8. Write a program that will find the maximum number from 3 float type numbers. You have to usethe function getMax which will take 3 pointer variables and return the maximum number.arrow_forward02. Create a word enlister program, a program that will enlist the words found in the inputted sentence and it will display the count of vowels and consonants in each words. Sample run: WORD ENLISTER PROGRAM Enter a phrase/sentence: The apple, banana, and chico are fruits >>Words Enlisted: [1] THE - 3 Letter (s) - 2 Consonant (s) - 1 Vowel (s) [2] APPLE - 5 Letter (s) - 3 Consonant (s) - 1 Vowel (s) [3] BANANA - 6 Letter (8) - 3 Consonant (s) - 3 Vowel (s) [4] AND 3 Letter (s) 2 Consonant (s) -1 Vowel (s) [5] CHICO - 5 Letter (8) - 3 Consonant (s) - 1 Vowel (s) [6] ARE - 3 Letter (8) 1 Consonant (8) - 2 Vowel (s) [7] FRUITS - 6 Letter (s) - 4 Consonant (s) - 2 Vowel (8) >> Enter 'Y' to try again: n Program Terminatedarrow_forwardA premutation of three objects a, b, and cm is any arrangement of these objects in a row. For example, some of the premutations of thee objects are abc, bca, and cab. The number of premutations of three objects is 6. Suppose thst these three objects are strings. Write a program that prompts the user to enter three Stings. The program then outputs the six premutations of those strings. This program must be in Java. Thank youarrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning