Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 8.2, Problem 16STE
Explanation of Solution
Program:
//Include necessary header files
#include <iostream>
#include<cstring>
//Declare namespace
using namespace std;
//Define the main() function
int main()
{
//String declaration
string s;
//Print the statement
cout<<"Enter a line of input:\n";
//Get the input string from the user
�...
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Decription key
Decryption Key
A|B|C| D|E|F|G|H|I|J|K|L|M
N|O|P|Q|R|S|T|U|V|W|X|Y|Z
(letter above equals below, and vice versa)
As you can see, A becomes N, B becomes O and so on.
Your job is to write a program, with at least four functions, including main, which must do the following:
1. Ask user whether they want to encode or decode a message - if no, then terminate
2. Take the input string from the user, store it in dynamic memory (use new)
3. As appropriate, encode or decode the message using Rot13.
4. Output the encoded/decoded message
5. Delete the input string from dynamic memory (use delete)
python programming.
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
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
- What is the return result of a function that lacks a return statement or has an empty return statement? Example: def x(a,b): print(x) returnarrow_forward2. Write a program that generates a number randomly by using rand ( ) function and user will have to guess that number. (Note: If the number is greater or smaller than user-entered number, your program should tell that the entered number is greater or smaller than computer-generated number and your program should terminate after correct number is guessed). sample program run is shown in the picture.arrow_forwardDefine function print popcorn_time() with parameter bag ounces. If bag ounces is less than 3, print "Too small". If greater than 10, print "Too large". Otherwise, compute and print 6* bag ounces followed by 'seconds". End with a newline. Sample output with input: 7 42 seconds 1 2 Your solution goes here *** 3 4 user_ounces int(input()) 5 print popcorn_time(user_ounces) Iarrow_forward
- In C++ Define a function named CoinFlip that returns "Heads" or "Tails" according to a random value 1 or 0. Assume the value 1 represents "Heads" and 0 represents "Tails". Then, write a main program that reads the desired number of coin flips as an input, calls function CoinFlip() repeatedly according to the number of coin flips, and outputs the results. Assume the input is a value greater than 0. Hint: Use the modulo operator (%) to limit the random integers to 0 and 1. Ex: If the random seed value is 2 and the input is: 3 the output is: Tails Heads Tails Note: For testing purposes, a pseudo-random number generator with a fixed seed value is used in the program. The program uses a seed value of 2 during development, but when submitted, a different seed value may be used for each test case. The program must define and call the following function:string CoinFlip()arrow_forward2. Test Scores File: test_scores.py Write pseudocode for the main() part of a program that asks the user to enter 4 test scores between 0 and 100, then displays a JCU grade for each score and also the average test score. When you have written the pseudocode for main, implement your solution in Python code and test it with a range of meaningful data. Remember that we've done the JCU grades question before, so copy your function from that practical code file. Sample Output Score: 3 Score: 50.5 Score: 66 Score: 100 Score 3.0, which is N Score 50.5, which is P Score 66.0, which is C Score 100.0, which is HD The average score was 54.875 Enhancements When you have that working... We asked for 4 scores. Have a look at your code... did you use 4 as a numeric literal or a constant?Change 4 to 3... Did you have to change the program in more than one place?If so, then you've missed one of the things we've taught...As a strong guideline: if you need to use the same literal more than once, you…arrow_forwardCode in Pythonarrow_forward
- Multiple Choice (single) Point:1 2/7 Which line is the definition of function Max? 1 #include int Max (int a,int b) ; int main( ) 4 int a,b,c; printf("please input a, b:"); scanf ("%d, %d",&a,&b) ; c = Max (a, b); printf("max=%d\n",c); 7 8 9 10 return 0; 11 12 int Max (int a,int b) 13 B{ 14 return (a>b) ?a:b; 15 } 16 A 2nd line В 12-15 lines c) 8th line Carrow_forwardWrite code to complete DoublePennies()'s base case. Sample output for below program:Number of pennies after 10 days: 1024 Note: These activities may test code with different test values. This activity will perform three tests, with startingPennies = 1 and userDays = 10, then with startingPennies = 1 and userDays = 40, then with startingPennies = 1 and userDays = 1. #include <iostream>using namespace std; // Returns number of pennies if pennies are doubled numDays timeslong long DoublePennies(long long numPennies, int numDays){long long totalPennies; /* Your solution goes here */ else {totalPennies = DoublePennies((numPennies * 2), numDays - 1);} return totalPennies;} // Program computes pennies if you have 1 penny today,// 2 pennies after one day, 4 after two days, and so onint main() {long long startingPennies;int userDays; startingPennies = 1;userDays = 10;cout << "Number of pennies after " << userDays << " days: "<< DoublePennies(startingPennies,…arrow_forward*Modify the program so that the user will error trap for only 1 and 0 as an input. *If the user enters an input other than 1 or 0 display an error message and request the user enter that input again. *Do this for all inputs in the code. # User defined function for logic OR# The function takes two parameters and returns a single intdef OR(a: int, b: int)->int:# If a is equal to 1 return 1if a == 1 :return 1# If b is equal to 1 return 1elif b == 1 :return 1# If a and b is equal to 0 return 0else :return 0 # User defined function for logic NOR# The function takes two parameters and returns a single intdef NOR(a: int, b: int)->int:# If a is equal to 0 and b is also equal to 0 return 1if a == 0 and b == 0 :return 1# If a is equal to 0 and b is equal to 1 return 0elif a == 0 and b == 1 :return 0# If a is equal to 1 and b is also equal to 0 return 0elif a == 1 and b == 0 :return 0# If a is equal to 1 and b is also equal to 1 return 0elif a == 1 and b == 1 :return 0 # User defined…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 LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr