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
Question
Chapter 16, Problem 3PP
Program Plan Intro
- Include required library files.
- Define a class named “Out_Range” and “Non_Digits”.
- Declare and define a function named “isAll_Digits()”.
- Declare the required variables.
- “for” loop to check the string contains only digits or not then return the Boolean result
- Initialize the constant value for maximum value.
- Define a “main()” function to test the histogram.
- “while” loop to handle the exception for the user giving inputs.
- Get the user input to print the result.
- Declare the required variables.
- “for” loop to check the string contains only digits or not then return the Boolean result
- Define a “main()” function to test the histogram.
- “while” loop to handle the exception for the user giving inputs.
- Get the user input to print the result.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
def swap_text(text):
Backstory:
Luffy wants to organize a surprise party for his friend Zoro and he wants to send a message to his friends, but he wants to encrypt the message so that Zoro cannot easily read it. The message is encrypted by exchanging pairs of characters.
Description: This function gets a text (string) and creates a new text by swapping each pair of characters, and returns a string with the modified text. For example, suppose the text has 6 characters, then it swaps the first with the second, the third with the fourth and the fifth with the sixth character.
Parameters: text is a string (its length could be 0)Return value: A string that is generated by swapping pairs of characters. Note that if the
Examples:
swap_text ("hello") swap_text ("Party for Zoro!") swap_text ("") def which_day(numbers):
→ 'ehllo'→ 'aPtr yof roZor!' → ''
length of the text is odd, the last character remains in the same position.
}/*** Adds letterGuessed to the current String updateLetterBoard* @param usedLetterBoard* @param letterGuessed* @param first* @return updateLetterBoard with letterGuess appended. */public static String updateLetterBoard(String usedLetterBoard, char letterGuessed, boolean first) {return "";}
IN C++
Write code that:
creates 3 integer values - one can be set to 0, the other two should NOT multiples of one another (for example 3 and 6, or 2 and 8)
take you largest value and perform a modulus operation using the smaller (non zero) value as the divisor
print out the result.
create an alias for the string type
call the alias "name"
then create an instance of the "name" class and assign it a value
using an appropriate cout statement - print out the value
Please screenshot your input and output, as the format tends to get messed up. Thank you!
Chapter 16 Solutions
Problem Solving with C++ (10th Edition)
Ch. 16.1 - Prob. 1STECh. 16.1 - What would be the output produced by the code in...Ch. 16.1 - Prob. 3STECh. 16.1 - What happens when a throw statement is executed?...Ch. 16.1 - In the code given in Self-Test Exercise 1, what is...Ch. 16.1 - Prob. 6STECh. 16.1 - Prob. 7STECh. 16.1 - What is the output produced by the following...Ch. 16.1 - What is the output produced by the program in...Ch. 16.2 - Prob. 10STE
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
- JAVA Programming Problem 5 – CharacterArray Write a program which will store the following string into a character array: 6901 Sudley Road Manassas VA Your program will display each original character, determine and display whether the character is a digit or a letter, and redisplay the character according to the directions below. Directions Create a class called CharacterArray. The scanner class is not required. Initialize the character array with the given string. Write a program which will accept an alpha numeric string at the keyboard. Store the string, of any length, into a character array, for example: RBDB Manassas Campus 6901 Sudley Road Manassas VA 20109 For each visible character: Display the original character Determine and display whether the character is a digit or a letter If the character is a lower case letter, redisplay the character in upper case If the character is a upper case letter, redisplay the character in lower case If the character is a digit, display it…arrow_forwarddef test_func(a,b,c): return (a+b)/c This function is normally designed to be used with three numbers: a, b, and c. However, a careless coder may call this function with an ill combination of arguments to cause certain exceptions. Specifically, if any of a, b or c is not a valid number, then this code will produce a TypeError; and if a and b are valid numbers, and c is 0, then the code will produce a ZeroDivisionError. Your job is to enhance this function by adding proper try...except... blocks, surrounding and capturing the exceptions. When a TypeError occurs, instead of crashing, your code must print on the screen: "Code produced TypeError". And, when a ZeroDivisionError occurs, instead of crashing, your code must print on the screen: "Code produced ZeroDivisionError". In both cases, your function will not crash, will not throw an exception, and silently return None.arrow_forwardC++ One common security function in check-writing requires that the amount be written in numbers and spelled out in words as well. Even if someone is able to alter the numerical amount of the check, it’s extremely difficult to change the amount in words. Write a program that receives a numeric check amount, that is less than $1000.00, from the user and writes the word equivalent of the amount. For example, the amount 112.43 should be written as: One Hundred Twelve and 43/100 dollars Do not accept invalid amounts. Allow the user to run the program as many times as possible until a sentinel value of zero (0) has been entered for the check amount. Don’t forget to include the developerInfo function. No input, processing, or output should happen in the main function. All work should be delegated to other functions. Include the recommended minimum documentation for each functionarrow_forward
- Write a function which computes the value of an arithmetic expression. The op should be one of ('+', '-', '*', or '/'). The function should throw an invalid_argument exception otherwise. You should also Also throw an invalid_argument if the op is '/' and the second argument is zero. #include <string>#include <stdexcept>using namespace std; /**Computes the value of an arithmetic expression.@param value1 the first operand@param op a char that should contain an operator + - * or /@param value2 the second operand@return the result of the operation */int compute(int value1, char op, int value2){ ... }arrow_forwardWord 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.” LINUX !#/bin/basharrow_forwardExercise Objectives Problem Description Write a program that reads a string and mirrors it around the middle character. Examples: abcd becomes cdab. abcde becomes deCab AhmadAlami becomes AlamiAhmad Page 1 of 2 Your program must: • Implement function void reflect (char* str) which receives a string (array of characters) and mirrors it. This function does not print anything. • Read from the user (in main()) a string and then print the string after calling function reflect(). • Use pointers and pointer arithmetic only. The use of array notation and/or functions from the string.h library is not allowed.arrow_forward
- Clearer instructionsarrow_forwardC++ Code: Write a program that finds word differences between two sentences. The input begins with an integer indicating the number of words in each sentence. The next input line is the first sentence and the following input line is the second sentence. Assume that the two sentences have the same number of words and no more than 20 words each. The program displays word pairs that differ between the two sentences. One pair is displayed per line. Ex: If the input is: 6 Smaller cars get better gas mileage Tiny cars get great fuel economy then the output is: Smaller Tiny better great gas fuel mileage economy Add a function named ReadSentences to read the input sentences into two string vectors. void ReadSentences(vector<string>& sentence1Words, vector<string>& sentence2Words, int wordCount) main() already contains code to read the word count and call ReadSentences(). Complete main() to display differing word pairs.arrow_forwardWrite a function that reverses a string. The header of the function is: def reverse(s):Write a test program that prompts the user to enter a string, invokes the reverse function, and displays the reversed string.arrow_forward
- Linux !#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_forwardAllowed libraries: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
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education