C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7, Problem 8PE
Write a
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
This program is a simple example of manipulating stringcontent.
On Line 8, we print out the first element of the stringstr1.
On Line 9, we accessed the first element of the stringstr2 and assigned the character ‘K’ to it. When
Line 10 is called, the content of str2 is now updated.
Line 12 shows us string concatenation.
What happened on Line 14?
Write a program that reads a character (string of length 1) from the user, and classifies it to one of the following: lower case letter, upper case letter, digit, or non-alphanumeric character.
Write a program that asks the user to enter a string, and then converts that string to Morse code. Use hyphens for dashes and periods for dots.
Morse Code Table
Character
Code
Character
Code
Character
Code
Character
Code
space
space
6
- . . . .
G
--.
Q
--.-
comma
--..--
7
-- . . .
H
. . . .
R
.-.
period
.-.-.-
8
---..
I
..
S
. . .
question mark
..--..
9
----.
J
.---
T
-
0
-----
A
.-
K
-.-
U
..-
1
.----
B
- . . .
L
.-..
V
. . . -
2
..---
C
-.-.
M
--
W
.--
3
. . . --
D
-..
N
-.
X
-..-
4
. . . .-
E
.
O
---
Y
-.--
5
. . . ..
F
..-.
P
.--.
Z
--..
Chapter 7 Solutions
C++ Programming: From Problem Analysis to Program Design
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- I have a string with a phrase in it, and I want to turn it into all caps using the function toupper. Write a code fragment that does that and then prints the resulting string.arrow_forwardTask 2: Implement the function Searchingstrings that allow to search a sub-string in a given string and display the: First occurrence, Last occurrence, First occurrence from a given index and Last occurrence from a given index. You can use the following String methods: string. IndexOf(searchvalue, start) return the position of the first occurrence of specified character(s) in a string. string.lastIndexOf(searchvalue, start) return the position of the last occurrence of specified character(s) in a string. You can use the following string to test your solution: var letters = "abcdefghijklmnopqrstuvwxyzabcdefghijklm"; Write the code in a separate.js and separate.html file.arrow_forwardIn Python Write a program that reads a string from the user containing a date in the form mm/dd/yyy. it should print the date in the format March 12, 2018.arrow_forward
- c++ , A character string is given. What is the minimum number of characters you need to change to make the resulting string of identical characters? Solve this task in 3 different manners using : sets, maps and deque ( 3 different codes ) Input output 69pop66 4 1+2=12 4arrow_forwardWrite a program that takes a string and creates a new string made of first two characters and last two characters from the given stringarrow_forwardWrite a program that converts among decimal, hex, and binarynumbers, as shown in Figure c. When you enter a decimal value in the decimal-value text field and press the Enter key, its corresponding hex and binarynumbers are displayed in the other two text fields. Likewise, you can enter valuesin the other fields and convert them accordingly. (Hint: Use the Integer.parseInt(s, radix) method to parse a string to a decimal and use Integer.toHexString(decimal) and Integer.toBinaryString(decimal) toobtain a hex number or a binary number from a decimal.)arrow_forward
- (This is a version with input of an exercise from Chapter 1.) Write a program thatinputs two string variables, first and last, which the user should enter with his or her name. First, convert both strings to all lowercase. Your program should then cre-ate a new string that contains the full name in pig latin with the first letter capitalized for the first and last name. Use only the pig latin rule of moving the first letter to theend of the word and adding “ay.” Output the pig latin name to the screen. Use thesubstring and toUpperCase methods to construct the new name.For example, if the user inputs “Walt” for the first name and “Savitch” for thelast name, then the program should create a new string with the text “AltwayAvitchsay” and print it.arrow_forwardWrite a program that takes a string as input and outputs the string in all capital letters and the length of the string. The output should follow the format from the example below. Example:Enter a DNA strand: aAtcDNA strand: AATCLength: 4Tip: make use of the .upper() method, the len() function, and the ‘\t’ escape character to add tabs.arrow_forwardWrite a python program that prompts your user a string input which will determine whether it is a valid email or not. As you all know, an email is composed of three parts. Let’s say we have an email, Benigno.Aquino@politics.ph. It begins with Benigno.Aquino which is called the local-part, followed by one @ symbol and ended by the domain name. To consider the input as a valid email, The local-part should only contain alphanumeric characters, dots and underscores @ character must only appear The domain name should only be consisted of hostname with alphanumeric characters only(min. of 2 characters), and a dot-separated DNS label(min. of 2 characters). Note: To simplify the problem, we’ll just limit our format to these characters, although other characters are actually allowed. Example: Input : missy.kuijamo@gmail.com Output: Valid Input: c_o_o_l@zxc.ph Output: Valid Input: tea_apple.us Output Invalid Input: chicken@macaroni@salad.uk Output: Invalidarrow_forward
- Write a Python Program to Count Occurrences of a certain Character in a String. The user inputs a string value and the character to search. For example, if the string input value is PHILIPPINES and the character value is P, the output is value 3. There are 3 occurrences of P in the PHILIPPINES. The program must count the same character whether it is in lowercase or uppercase.arrow_forwardGiven two lists – "name" and "score". Each of them has 10 elements respectively. All elements in "name" are strings while all elements in "score" are integers. Any element in "name" maps to the same position in "score". Now please fill in with format operators in the incomplete code snippet below to print this way:"2-digit integer, up to 8 characters: 3-digit integer". For example: 5,Jacky : 90 for i in range(10: print ('{_______}, {:______}:{:_____}'.format(i,name[i], score[i])) I code that in Python but the three missing on the print section i got an errorarrow_forwarda) Write code to modify strings1.py (below) to: i) Convert instring to uppercase and print itii) Print the string going forwards with for-range, starting at the fourth letterand printing every third letter ("A Moose Once Bit My Sister" would become "oen tyie")iii) Print the string going forwards with slicing, starting at the fifth letter, endingat the third-last letter and printing every second letter ("A Moose Once Bit My Sister " would become " oeOc i ySs ")## strings1.py: Read in a string and print it in reverse#instring = input('Enter a string... ')# Example: reversing with a for-range loop##print('String is : ', end='')#for index in range(len(instring)-1,-1,-1):# print(instring[index], end='')## Example: reversing with slicing##print('String is :', instring[::-1]) Submit separately as a python file.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Computer Programming for Beginners | Functions, Parameters & Arguments | Ep24; Author: Programming With Avelx;https://www.youtube.com/watch?v=VXlh-qJpfw0;License: Standard YouTube License, CC-BY