Microsoft Visual C#
7th Edition
ISBN: 9781337102100
Author: Joyce, Farrell.
Publisher: Cengage Learning,
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 11, Problem 1CP
Program Plan Intro
- In the class GreenVilleRevenue include the code related to number of contestant entry under the try catch block. Catch the exception in catch block and display the exception message using Message property.
- As done above include the code for talent code entry and talent category entry under the try catch block.
Program Description:
The main purpose of the program is to modify the GreenVilleRevenue program from previous chapter to handle the exceptions related to number of contestants input, and talent codes input.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Modify the GreenvilleRevenue program created in Chapter 10, Case Study 1 so that it performs the following tasks:
The program prompts the user for the number of contestants in this year’s competition; the number must be between 0 and 30. Use exception-handling techniques to ensure a valid value and display the error message:Number must be between 0 and 30
The program prompts the user for talent codes. Use exception-handling techniques to ensure a valid code and update the displayed message to the following message:x is not a valid talent code. Assigned as Invalid.where x was the invalid code entered into the console.
After data entry is complete, the program prompts the user for codes so the user can view lists of appropriate contestants. Use exception-handling techniques for the code verification and display the following message:
Enter a talent type or Z to quit >> x x is not a valid code
and for valid codes:
Enter a talent type or Z to quit >> S Contestants with talent…
Modify the GreenvilleRevenue program created in Chapter 10, Case Study 1 so that it performs the following tasks:
The program prompts the user for the number of contestants in this year’s competition; the number must be between 0 and 30. Use exception-handling techniques to ensure a valid value and display the error message:Number must be between 0 and 30
The program prompts the user for talent codes. Use exception-handling techniques to ensure a valid code and update the displayed message to the following message:x is not a valid talent code. Assigned as Invalid.where x was the invalid code entered into the console.
After data entry is complete, the program prompts the user for codes so the user can view lists of appropriate contestants. Use exception-handling techniques for the code verification and display the following message:
Enter a talent type or Z to quit >> x x is not a valid code
and for valid codes:
Enter a talent type or Z to quit >> S Contestants with talent…
Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burning_heart_rate() to calculate the fat burning heart rate.
The adult's age must be between the ages of 18 and 75 inclusive. If the age entered is not in this range, raise a ValueError exception in get_age() with the message "Invalid age." Handle the exception in __main__ and print the ValueError message along with "Could not calculate heart rate info."
Ex: If the input is:
35
the output is:
Fat burning heart rate for a 35 year-old: 129.5 bpm
If the input is:
17
the output is:
Invalid age.
Could not calculate heart rate info.
**This is the output i am having trouble with. on line 20 The print string shows the print(ve, 'could not calculate heart rate info.') And i know that the extra space i see at the begining of that second line of output is due to the comma but I cannot figure out how to make the same line print but with out the space from the comma after…
Chapter 11 Solutions
Microsoft Visual C#
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
- Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burning_heart_rate() to calculate the fat burning heart rate. The adult's age must be between the ages of 18 and 75 inclusive. If the age entered is not in this range, raise a ValueError exception in get_age() with the message "Invalid age." Handle the exception in __main__ and print the ValueError message along with "Could not calculate heart rate info." Ex: If the input is: 35 the output is: Fat burning heart rate for a 35 year-old: 129.5 bpm If the input is: 17 the output is: Invalid age. Could not calculate heart rate info. **This is the output i am having trouble with. on line 20 The print string shows the print(ve, 'could not calculate heart rate info.') And i know that the extra space i see at the begining of that second line of output is due to the comma but I cannot figure out how to make the same line print but with out the space from the comma after…arrow_forwardC++ You did this way back in Unit 1! But now all of your RomanNumber code is wrapped up in a class, so the "main" program is short and sweet. As before, write a program that accepts entries from the user. If it's an integer, convert to Roman Number and display. If it's a Roman Number, convert to integer and display. If it's neither, thrown an exception and continue to process The action to take here will be to display an error message If the entry is 0 or O (The digit 0 (zero) or the letter O) exit and state how many conversions were done of each type (integer to Roman and Roman to integer) and how many exceptions were thrown. As I said, the main program will be short and sweet. Provide your .cpp code and a screen shot of your program in action. Enter twelve conversions - four integer to Roman, four Roman to integer, and two of each in which the input is invalid so that I can see the exceptions. The thirteenth and final entry will be 0 or O.arrow_forwardI need to know how to do this in python: Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burning_heart_rate() to calculate the fat burning heart rate. The adult's age must be between the ages of 18 and 75 inclusive. If the age entered is not in this range, raise a ValueError exception in get_age() with the message "Invalid age." Handle the exception in __main__ and print the ValueError message along with "Could not calculate heart rate info." Ex: If the input is: 35 the output is: Fat burning heart rate for a 35 year-old: 129.5 bpm If the input is: 17 the output is: Invalid age. Could not calculate heart rate info.arrow_forward
- Please do this in Java! 3. RetailItem Exceptions Programming Challenge 4 of Chapter 6 required you to write a RetailItem class that holds data pertaining to a retail item. Write an exception class that can be instantiated and thrown when a negative number is given for the price. Write another exception class that can be instantiated and thrown when a negative number is given for the units on hand. Demonstrate the exception classes in a program. /** *Description: This program will displays a string without any user interaction *Class: Fall - COSC 1437.81002 *Assignment1: Hello World *Date: 08/15/2011 *@author Zoltan Szabo *@version 0.0.0 */ For each method, you will also be required to create docstring as follows: /** * @param String as args * @return Termination code as int, 0 for normal, anything else is error condition * @throws Nothing is implemented */ Flowcharts/UML and Pseudo code All assignment questions must show design flowchart/UML and/or pseudo code unless otherwise…arrow_forwardThis lab will exercise your understanding of some of the concepts covered in Chapter 14: exception handling 1. Create a program that uses EXCEPTION HANDLING to deal with an invalid input entry by a user. a. Write a program that prompts a user to enter a length in feet and inches. The length valuesmust be positive integers. b. Calculate and output the equivalent measurement in centimeters1. inch = 2.54 centimeters c. Write the code to handle the following exceptions: If the user enters a negative number, throw and catch an error that gives the user the appropriate message and request a valid number. Do this until the user enters a valid number If the user enters a character, throw and catch an error that indicates the input stream is invalid. Write code that resets the input stream and request a valid number. Do this until the user enters a valid number d. Output the feet-inch input values to centimeter conversion value The program may be named any name of our choice, must have a .cpp…arrow_forwardDerive exception classes from the class you wrote in the previous exercise. Each new class should indicate a specific kind of error. For example, InvalidHourException could be used to indicate that the value entered for an hour was not an integer in the range of 1 to 12. (Also the previous answer was not preferd from the teacher cause its not simple and use def which we arent taken it)arrow_forward
- (Please use JAVA) Create custom exception and implement exception handling Create the following classes based on the UML Class diagram: - Employee - InvalidUserDetailException - EmployeeValidation-uses the custom InvalidUserDetailException class. This class contains an instancemethod validateInput() which will validate the employee details (name, age & gender) based on the specified criteria. * If employee details are within the criteria, employee details will be outputted in the console. * If employee details are not within the criteria, InvalidUserDetailException will be thrown with a message informing user that employee detail inputted is invalid. Create Employee Main class which will contain the main() method main() method will allow user to input employee name, age and gender. Calls validateInput() to validate the employee details.arrow_forwardWhich of the following statements is false? A software developer can write his own exceptions in Java. A try statement is associated with one and only one catch statement.. A programmer written Exception implements the Exception interface. None of the above statements are falsearrow_forwardWrite an exception class that is appropriate for indicating that a time enteredby a user is not valid. The time will be in the format hour:minute followed by“am” or “pm.”arrow_forward
- Write a program that includes the <exception> header using the pre-processor directive. Then create a class named MyException that inherits all properties from the exception class. In that class create a function what() which basically returns an error message string (“C++ Exception”). Finally inside the main function create a try{}…catch() block and inside the try block create an object of MyException class and use the throw keyword to explicitly throw an exception using this object.(answer this in c++ programming language)arrow_forwardBELOW MCQ GIVEN ANSWER CAN BE MORE THAN ONE OPTION. PLEASE PROVIDE CORRECT ANSWERS. ------------------- Which of the following statements accurately describe the C++ code except below ? int* arr = new int [10]; delete arr; A) delete will fail. B) the compiler will emit a diagnostic error. C) an exception may be thrown at runtime . D) delete[] arr; must be used to properly deallocate arr. E) the free-store may be corrupted.arrow_forwardWrite a Python program that writes user input to a CSV file, reads the data back from the CSV file, and incorporates exception handling. You will perform the following steps: Prompt the user to enter their name, age, and email address. If the user does not enter a valid age (i.e., a positive integer), your program should catch this error and ask for the input again. Open a new file in write mode named user_info.csv and write the user's information to this file in CSV format. Make sure you handle exceptions if you do not have write permissions for the file or other IO errors occur. Now open the user_info.csv file in read mode. Make sure your code handles any exceptions if the file is not found or other IO errors occur. Read the content of the file and store it in a variable. Print the contents of this variable to the console/shell. Provide comments in your code to explain the logic used.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++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT