Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 8, Problem 2P
Program Plan Intro
- Include the necessary header files.
- Declare the namespace.
- Define the “main()” function.
- Declare the necessary variables.
- Initialize the string.
- Use the functions “substr()” to return the newly constructed string.
- Use the function “find()” to find the space
- Print the result.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
python function!: a function called popular_color with one parameter, of type dict[str, str] of names and favorite colors. The return type is a str and it is the most commonly occuring color. If two colors are tied for popularity, the first color shown will be picked.
In this assignment you will be responsible for writing several string validation and manipulationfunctions. The assumption will be that you are writing functions that will take input from a form andmanipulate or validate the information entered before it is processed into a database. A database is acollection of information but the information in the database must always be entered in a specificformat. Your responsibility will be to take data entered into a program and be sure it is writtencorrectly before it is entered into the database.Each function will have to have a specific name and heading. Each function will also need to includea docstring, the correct logic, and the proper return. Each function will be given a specific set ofpreconditions and postconditions/returns. A precondition is something you may assume to be truewhen the function is executed. A post condition is something you need to be sure is completed whenthe function is executed. Be sure to test each one of your…
About beginner python programming:
-
Make a function in Python called SIGA, which receives a tuple containing 4 pieces of information: the nameof the student and his three respective grades. Your function should return a tuple, whose first element is the student's name,the second element is the grades average, and the third element is the student's situation, which must be representedby a string. If the average of the three grades of the student is greater than or equal to 7 (inclusive), the function should bereturn: (<name>, <average>,’approved’, ’Congratulations!́). If the student's average grades is less than 7 but greater than or equal to 5, your function should return: (<name>, <average>,’approved’). If the average is smallerthan 5, the function should return (<name>, <media>,’failed’). This function should return the averagewith one decimal place only.
Chapter 8 Solutions
Problem Solving with C++ (10th Edition)
Ch. 8.1 - Prob. 1STECh. 8.1 - What C string will be stored in singingString...Ch. 8.1 - What (if anything) is wrong with the following...Ch. 8.1 - Suppose the function strlen (which returns the...Ch. 8.1 - Prob. 5STECh. 8.1 - How many characters are in each of the following...Ch. 8.1 - Prob. 7STECh. 8.1 - Given the following declaration and initialization...Ch. 8.1 - Given the declaration of a C-string variable,...Ch. 8.1 - Write code using a library function to copy the...
Ch. 8.1 - What string will be output when this code is run?...Ch. 8.1 - Prob. 12STECh. 8.1 - Consider the following code (and assume it is...Ch. 8.1 - Consider the following code (and assume it is...Ch. 8.2 - Consider the following code (and assume that it is...Ch. 8.2 - Prob. 16STECh. 8.2 - Consider the following code: string s1, s2...Ch. 8.2 - What is the output produced by the following code?...Ch. 8.3 - Is the following program legal? If so, what is the...Ch. 8.3 - What is the difference between the size and the...Ch. 8 - Create a C-string variable that contains a name,...Ch. 8 - Prob. 2PCh. 8 - Write a program that inputs a first and last name,...Ch. 8 - Write a function named firstLast2 that takes as...Ch. 8 - Write a function named swapFrontBack that takes as...Ch. 8 - Prob. 6PCh. 8 - Write a program that inputs two string variables,...Ch. 8 - Solution to Programming Project 8.1 Write a...Ch. 8 - Write a program that will read in a line of text...Ch. 8 - Give the function definition for the function with...Ch. 8 - Write a program that reads a persons name in the...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that can be used to train the user...Ch. 8 - Write a sorting function that is similar to...Ch. 8 - Redo Programming Project 6 from Chapter 7, but...Ch. 8 - Redo Programming Project 5 from Chapter 7, but...Ch. 8 - Prob. 11PPCh. 8 - Write a program that inputs a time from the...Ch. 8 - Solution to Programming Project 8.14 Given the...Ch. 8 - Write a function that determines if two strings...Ch. 8 - Write a program that inputs two strings (either...Ch. 8 - Write a program that manages a list of up to 10...
Knowledge Booster
Similar questions
- Write a complete C++ program that asks the user to input information for at least 10 students. Use structure for the information below: Name of the student, Matric No, Course No, Obtained Marks ragr The program should then display the information based upon marks in ascending and descending order. To solve ascending and descending order the program should have two functions that have an array of structure as a parameter and the functions should be called from the main function.arrow_forwardWrite a program that reads in a line consisting of a students name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [] to access a string element. Use the appropriate functions described in Table 7-1.arrow_forwardCode using c++ 3. From Person to People by CodeChum Admin Now that we have created a Person, it's time to create more Person and this tech universe shall be filled with people! Instructions: In the code editor, you are provided with the definition of a struct Person. This struct needs an integer value for its age and character value for its gender. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. In the main() function, there's a pre-created array of 5 Persons. Your task is to ask the user for the values of the age and gender of these Persons. Then, once you've set their ages and genders, call the displayPerson() function and pass them one by one. Input 1. A series of ages and genders of the 5 Persons Output Person·#1 Enter·Person's·age:·24 Enter·Person's·gender:·M Person·#2 Enter·Person's·age:·21 Enter·Person's·gender:·F Person·#3 Enter·Person's·age:·22 Enter·Person's·gender:·F Person·#4…arrow_forward
- True/False 3. Information can be passed into a function through parameters.arrow_forwardPlease complete the exercise as instructed and do not use global variables. Please follow the guidelines of what the solution cannot use provided in the second picture. Thank you!arrow_forwardQ3 Write a program in C ++, with a row in the name (Shape), to calculate the total area of the figure below. For each geometry, use a function to calculate its participation area, noting that the area of the triangle = 1/2 (base * height)arrow_forward
- C program Write 2 functions that can convert an input string to all lowercase and to all uppercase. Write a program to illustrate the use of these 2 functions. Test Data: Input the string: ComputerEngineering Output: Lowercase: computerengineering Uppercase: COMPUTERENGINEERINGarrow_forwardUSE PYTHON Source: en.wikipedia.org/wiki/Camel_case In some languages, it’s common to use camel caseLinks to an external site. (otherwise known as “mixed case”) for variables’ names when those names comprise multiple words, whereby the first letter of the first word is lowercase but the first letter of each subsequent word is uppercase. For instance, whereas a variable for a user’s name might be called name, a variable for a user’s first name might be called firstName, and a variable for a user’s preferred first name (e.g., nickname) might be called preferredFirstName. Python, by contrast, recommendsLinks to an external site. snake caseLinks to an external site., whereby words are instead separated by underscores (_), with all letters in lowercase. For instance, those same variables would be called name, first_name, and preferred_first_name, respectively, in Python. In a file called camel.py, implement a program that prompts the user for the name of a variable in camel case and outputs…arrow_forwardDefine a struct fruitType to store the following data about a fruit: Fruit name (string), color (string), fat (int), sugar (int), and carbohydrate (int). Declare a variable of type fruitType to store the following data: Fruit name—banana, color—yellow, fat—1, sugar—15, carbohydrate—22. Write a C++ function, getFruitInput to get and store data into a variable of fruitType. Write a C++ function, printFruitInfo to output data stored into a variable of fruitType. Use appropriate labels to identify each component. Test your solution by calling all funtions.arrow_forward
- In C programming language. Objectives:• Use of functions and passing by value and reference.• Use of selection constructs.• Use of repetition constructs (loops).• The use of the random number generator and seeding.• Display formatted output using input/outputstatements.• Use format control strings to format text output. Description: For this project you are tasked with building a user application that will select sets of random numbers. Your application must use functions and pass values and pointers. Your program will pick sets of 6 random numbers with values of 1 to 53. The user should be able to choose how many sets to produce. The challenge will be to ensure that no number in a set of 6 numbers is a repeat. The number can be in another set just not a duplicate in the same set of 6. Your program should prompt the user and ask them how many number sets they wish to have generated. The program should not exit unless the user enters a value indicating they wish to quit. Minimum…arrow_forwardWord Count Problem Consider that you have been hired to design in C++ the program that will count the number of words in a MS document. Use the pre-defined member function of the class string to design this program. For simplicity, the user should enter a sentence using the keyboard, read it using the getline function, and then respond back to the user with how many words are there in that sentence. Document Microsoft Word non-commercial use Home Insert Page Layout References Mailings Review View 出,而, E事 , Arial 11 BI U. x, x' || Quick Change Editing Styles- Styles Paste S . A. Aa A A Clipboard - Font Paragraph Styles 9. 10 !! 12 11'14.115.1 16'A Data Scientist typical Job Requirements: Find, clean, and organize data for companies. Data scientists will need to be able to analyze large amounts of complex raw and processed information lo find pattems that will benefit an organization and help drive strategic business decisions. Page: 1 of 1 Words: 43 V English (Canada) %06 Oarrow_forwardCan you use Python programming language to to this question? Thanksarrow_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