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 6PP
Program Plan Intro
- Include required library files.
- Define a “throwExcepAt()” function to throw exception at user input level.
- Check “currLevel” is not equal to “excepLevel” using “if” statement.
- The condition is true, print calling depth.
- Call “throwExcepAt()” function to calling depth recursively.
- Define a “main()” function.
- Declare and initialize an integer variable.
- Get the input from user to throw exception.
- Assign the input to the variable.
- “try” block to call “thrwoExcepAt()” function with two arguments
- “catch” block to print the exception thrown message.
- Check “currLevel” is not equal to “excepLevel” using “if” statement.
- The condition is true, print calling depth.
- Call “throwExcepAt()” function to calling depth recursively.
- Declare and initialize an integer variable.
- Get the input from user to throw exception.
- Assign the input to the variable.
- “try” block to call “thrwoExcepAt()” function with two arguments
- “catch” block to print the exception thrown message.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
design the python program solution to solve the problem of determining a student's letter grade given the final score as an integer.
Your program should have the following modules:
def main() - the general flow of the program.
def getFinalScore() - this function should ask for input from the user. The function should raise an exception if the score is not an int and should also raise an exception if the score is outside the range of 0 and 100. The program should return the score entered by the user if no exception is raised.
def determineLetter(score) - this module should accept a score variable and check/print if the letter grade is A (90 - 100), B (80 - 89), C (70 - 79), D (60 - 69) or F (0 - 59).
Remember to call main at the end of the module definitions
Using C++
Write a void function GetYear that prompts for and inputs the year the operator was born (type int) from standard input. The function returns the user’s birth year through the parameter list (use pass by reference) unless the user enters an invalid year, in which case a BadYear exception is thrown. To test for a bad year, think about the range of acceptable years. It must be 4 digits (i.e. 1982) and it cannot be greater than the current year (the user obviously cannot be born in a calander year that has yet to happen!
Write a program using the C ++ OOP language,
and the program should contain at least the
following to four topics
Inheritance
Operator Overloading
Vector
Template
Exception Handling
File Stream
Friend function and Friend class
The following must be taken into account:
1- The arrangement
2-The idea of the program
3- The topics that have been chosen
4 - A simple explanation of the program's
work
5- Writing comments explaining each step of
the program
6- Show the implementation screen
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
- You are assigned to develop a C++ Program using Classes, Functions, Arrays and Pointers that requires users to enter their own passwords. Your software requires that user’s passwords meet the following criteria: The password should be at least sixteen (16) characters long. The password should contain at least: one uppercase letter one lowercase letter one digit one special character (no spaces) Write a program that asks for a password and then verifies that it meets the stated criteria. If it doesn’t, the program should display a message telling the user why. Whenever possible, use pointers. Manually destroy any memory used when finished using it.arrow_forwardUsing C++ Write the section of code which takes an array of characters and copies it to another array of characters. At this point two arrays of characters should hold the same name. You will need to use one of the loop instructions to do this. You can't use any built in functions. Write a second section of code which concatenates two arrays of characters into a third array of characters. The first array (which holds the first name) will be copied into the third array and the second array (which holds the last name) will be concatenated onto the third array. Once you are done filling in the arrays you should output the two sentences below. You are given the example input and output below.Example Input: Input first name -> FredInput last name -> SmithExample output: Your first name is Fred and the copy of your first name is Fred. Your first name is Fred and your last name is Smith and the concatenation is FredSmith.arrow_forwardC++ code please (5) Implement the FindText() function, which has two strings as parameters. The first parameter is the text to be found in the user provided sample text, and the second parameter is the user provided sample text. The function returns the number of instances a word or phrase is found in the string. In the PrintMenu() function, prompt the user for a word or phrase to be found and then call FindText() in the PrintMenu() function. Before the prompt, call cin.ignore() to allow the user to input a new string.Ex: Enter a word or phrase to be found: more "more" instances: 5arrow_forward
- Suppose you are writing a C++ function that has three alternativeapproaches for accomplishing its requirements. Write a skeletal versionof this function so that if the first alternative raises any exception, thesecond is tried, and if the second alternative raises any exception, thethird is executed. Write the code as if the three methods were proceduresnamed alt1, alt2, and alt3.arrow_forwardCode using c++ 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 a character value for its gender. Furthermore, you are provided with a displayPerson() function which accepts a struct Person as its parameter. In the main(), there are two Persons already created: one Male Person and one Female Person. Your task is to first ask the user for the age of the Male Person and the age of the Female Person. Then, define and declare a function called createKidPerson() which has the following definition: Return type - Person Name - createKidPerson Parameters Person father - the father of the kid to be created Person mother - the mother of the kid to be created Description - creates a new Person and returns this. The age of this Person will be set to 1 while its gender will be set based on the rules mentioned above. Finally, create a new Person and call this createKidPerson() in the main and then…arrow_forwardSecuring data is very important. We are developing an encryption module for the communication system in C++. You are supposed to input data in a character array of size 100. After taking input in array pass this array to a function to encrypt. This function applies following encryption on data. For testing purposes, after encryption function is called, the main function should print the encrypted data in the array. Convert upper case letters to lower case and lower case letters to upper case. After conversion replace each alphabet with its next alphabet, for example “A” will be replaced by “B”, “B” will be replaced by “C”, and so on. Similarly “a” will be replaced by “b” etc. However, “Z” should be replaced by “A” and “z” should be replaced by “a”. Digits must be replaced by subtracting it from 9 for example 0 should be replaced by 9 (9-0=9), 1 should be replaced by 8 (9-1=8), 2 should be replaced by 7 (9-2=7)………… and 9 should be replaced by 0 (9-9=0). Spaces should be replaced by $…arrow_forward
- In C++, Write a complete program to call a function that swaps the values stored in two variables. The function accepts two parameters x and y which are to be swapped. The parameters can be of any data-type.arrow_forwardC++ ONLYarrow_forwardwrite a c++ program in wich you have to Declare a two-dimensional array which can be used to store a yearly budget.Each row of the array corresponds to a particular budgeted item like rent, electric,etc. There are at most 15 items to be budgeted. Each column of the array correspondsto a month, January, February, etc. Of course there are 12 columns corresponding tothe 12 months of the year. All the data to be placed in the array consists of realnumbers.arrow_forward
- Question 22 Write a program that reads integers user_num and div_num as input, and output the quotient (user_num divided by div_num). Use a try block to perform all the statements. Use an except block to catch any ZeroDivisionError and output an exception message. Use another except block to catch any ValueError caused by invalid input and output an exception message. Please do it ONLY in Python Language also inlcude the input and output screenshotarrow_forwardCode Should Be In C++arrow_forwardWrite a C++ program to facilitate the usage of several string-handling functions. The program should present a menu for the choices available. The options might be to create, insert, append, erase, reverse, and print. The program should ask the user what required by the function to prepare the real function call. For instance, for the insert function, the string might be printed on the screen as a reminder first, and then the start and finish indexes might be requested from the user. You should be aware of the run-time issues that might result due to user mistakes. Try to prevent them!arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning