12.6 LAB: Fat-burning heart rate 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:
Q: 2.14 LAB: Exception handling to detect input string vs. integer The given program reads a list of…
A: Coded using Python 3.
Q: 20.8 LAB: Exception handling to detect input string vs. integer The given program reads a list of…
A: The Answer is in the below Steps
Q: Using JAVA (Catching Exceptions with Superclasses) Use inheritance to create an exception…
A: Program Approach: Creating class Exception A Declaring string variable msg Creating parameterized…
Q: ANSWER IN JAVA Standard Output: Enter·side·length·of·square:Side·length·must·be·greater·than·0.↵…
A: In this question we are asked to write a java program for calculating the area of square. Algorithm:…
Q: Donor Eligibility Write a C++ program to handle the exception. Read all the details and check for…
A: Here I have created variables to store the information. Next, I have created a try block. Inside the…
Q: 1) X= 500 Note: x should not be bigger than 100. Raise an exception that would result in an error if…
A: I have provided solution for first 3 parts------------- For each part , I have provided PYTHON…
Q: Exercise # 2 Write a program that asks the user to input a set of floating-point values. When the…
A:
Q: please code in python Write a function called weighted_avg that takes a list of grades and a…
A: raise allows you to throw an exception at any time.
Q: 3.Write a java program that will ask user to enter date in format dd-mm-yyyy in three different…
A: Programs: The program contains the instructions to solve the problems and returns the result. The…
Q: Program 3 Write a programmer-defined function to find the area of circle. Add a decorator function…
A: Algorithm: Start Implement a decorator function Error_Handler() which raises an exception if the…
Q: 10. (Useful utility) Write and execute a C++ function named getaReal() that uses exception handling…
A: Note: Below is the required C++ program. Programming Approach: Define necessary header files. A…
Q: Q. Run and find output • class Name: • def _init_(self, FName, mi, LName): self. FName = FName…
A: class Name: def_init__(self, FName, mi, LName) self.FName = FName self.mi = mi…
Q: Create a class Int in oop c++ that contain an integer variable. Overload the following integer…
A: PROGRAM: #include<iostream> using namespace std; //Defining class class Int { private:…
Q: Convert the following code into "JAVA SCRIPT" (please run the code and show output. Also please do…
A: import java.io.*; // The exception definition to deal with the end of data class…
Q: 1.4 You are required to use try-except, exception handling statement in the correct position to…
A: Code a=5b=0try: result =a/b print(result)except ZeroDivisionError: print("You can't divide…
Q: Exercise 4 - Simple Calculator with Exception Handling Create a new class called SimpleCalc. In this…
A: Program:- import java.io.*;import java.lang.*;import java.lang.Math;import java.util.Scanner;public…
Q: Program 6 Use nested (or inner) functions, closure and decorators to write menu driven program to…
A: import math def decorator(radius, choice): # decorator function if…
Q: Cs101: Lab #14 Exceptions Part I Write a Java program that repeatedly accepts two integers from the…
A: According to the information given:- We have to create the division program in which the we take…
Q: Write a code in JAVA for the following. A university is going to conduct the placements for the…
A: Note: This code should be rewritten instead of copying to the compiler otherwise it will throw a…
Q: 1. Write a java program to display the A) Arithmetic exception. B) Array bounds exception. C)…
A: As per out guidelines we are supposed to answer only one question. Kindly repost other questions as…
Q: 1) X = 500 Note: x should not be bigger than 100. Raise an exception that would result in an error…
A: NOTE: AS per student asked, I answered the question with coding and print the output Use python an…
Q: 1. DivideByZeroException as a derived class of Standard Library class runtime_error, that is used to…
A: Summary:In this question, we need to implement a function with its own exception class.
Q: Write a programmer defined function to find the perimeter of circle. Add a decorator function to…
A: According to the Question below the Solution: Output:
Q: Write a program that takes a singular form of a noun and produces the plural form. For most nouns,…
A: Please find the answer below :
Q: Question 7 Consider the following code fragment. What would be the expected output given age = -10?…
A: Answer is option (B) "Invalid age. less than 0." Code: #include <iostream> using namespace…
Q: 4. Write a python program to test the class TornadoExcetion specified to this: Define an exception…
A: the answer is given below:-
Q: 1. Suppose you have given the following line of code: int a[3] = {2, 3, 4, 5} If the above line has…
A: Given line of code: int a[3]={2,3,4,5}; The equivalent java code for the above line: int[] a=new…
Q: Program 4 Write a programmer defined function to find the perimeter of circle. Add a decorator…
A: As per our guidelines, we are supposed to answer only one question. Kindly repost the remaining…
Q: 4.10 LAB: Exception handling to detect input string vs. integer The given program reads a list of…
A: Here I have taken input from the user and then stored it into a variable by splitting them on the…
Q: Define a class called GATE consisting of members Name, College, Qualification, Email, and CGPA.…
A: Here I have created custom classes for generating exceptions. Now I have created the class Gate with…
Q: Write Java code to show an example of using a complete try-catch statement. Include actual code that…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Description: Implement function getPercentage that takes two inputs: grade and total Grade and…
A: Actually, Java is a general-purpose also class-based, object-oriented programming language designed…
Q: catch
A:
Q: 1.(A)Wite a C++ program containing a possible exception. Use a try block to throw it and a catch…
A: According to our guidelines, we are supposed to answer only 1 question. So I am answering the first…
Q: 1. Write a function which will return the fraction part after dividing a number by another. The…
A: According to the Question below the Solution: Output:
Q: Can i get solution for b a. Create a CourseException class that extends Exception and whose…
A: EXCEPTION HIERARCHY IN JAVAChecked ExceptionUnchecked/Runtime ExceptionError Checked exception is a…
Q: python Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus…
A: Code: def get_age():# function for age age = int(input()) if(age>=18 and…
Q: ** 12.20 (Remove package statement) Suppose you have Java source files under the direc- tories…
A: Programming approach Importing the required packages in the program. Obtain the file path as…
Q: Create a CourseException class that extends Exception . Create a Course class with String that holds…
A: [Note: This code should be rewritten instead of copying to the compiler otherwise it will throw a…
Q: T/F 9. An ArithmeticException is a kind of exception that is verified.
A: please see the next step for solution.
Q: Write a program (CoconutCherry that This program should accept multiple numbers as command line…
A: Part 1 import java.util.*; //generic class to hold different types of objects class…
Q: Implement function getPercentage that takes two inputs : grade and totalGrade and outputs the grade…
A: Create 3 User defined Exceptions inheriting from run_time error Assign the string to what message so…
Q: T/F 2) Anywhere in the software an exception is raised, the programme terminates
A: Given that, Anywhere in the software an exception is raised, the programme terminates.
Q: 23) If x is a char, and values is an int array, then values[x] a) causes a syntax error b) causes an…
A: please see the next step for solution
Q: 12.5 LAB: EXception handling to detect Input string Vs. Integer The given program reads a list of…
A: Since no programming language is mentioned, I am using python. Algorithm: Start Declare an empty…
Q: he user to enter a hex number as a string and display the number in decimal. If the function throws…
A: Write a test program that prompts the user to enter a hex number as a string and display the number…
Q: 12.20 (Remove package statement) Suppose you have Java source files under the direc- tories…
A: Here is the solution of the above program:
Q: T/F 5) If an exception occurs in a catch phrase, then the violation class matches. For instance, if…
A: Given that, If an exception occurs in a catch phrase, then the violation class matches. For…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- 5.12.2: Switch statement to convert letters to Greek letters. Write a switch statement that checks origLetter. If 'a' or 'A', print "Alpha". If 'b' or 'B', print "Beta". For any other character, print "Unknown". Use fall-through as appropriate. End with newline. import java.util.Scanner; public class ConvertToGreek {public static void main (String [] args) {Scanner scnr = new Scanner(System.in);char origLetter; origLetter = scnr.next().charAt(0); /* Your solution goes here */ }}7.21 LAB: Random values use Java. In the file RandomNumbers.java, write a class called RandomNumbers that has three integer instance variables: var1, var2, and var3. Write getter method for each variable: getVar1(), getVar2() and getVar3(). Then write the following 2 instance methods: setRandomValues( ) - accepts a low and high integer values as parameters, and sets var1, var2, and var3 to random numbers (generated using the Random class) within the range of the low and high input values (inclusive). getRandomValues( ) - prints out the 3 random numbers in the format: "Random values: var1 var2 var3" Ex: If the input is: 15 20 the output may be: Random values: 17 15 19 where 17, 15, 19 can be any random numbers within 15 and 20 (inclusive). Note: When submitted, your program will be tested against different input range to verify if the three randomly generated values are within range. import java.util.Scanner; public class LabProgram {// main method used to test your codepublic…T/F 2) Anywhere in the software an exception is raised, the programme terminates.
- Python please: Write a square_root() function that takes a number and returns the square root. The square_root() function throws a ValueError object with the message "Exception: Negative input for square root entered." when the number is negative. Complete the main() program that reads a number from a user, calls the square_root() function, and outputs the returned value from the square_root() function. Use a try-except block to catch any ValueError object thrown by the square_root() function and output the exception message. If the user enters something other than an integer, the program throws a ValueError object with the message "invalid literal for int() with base 10: " and 'user_input'. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: print('{:.2f}'.format(your_value)) Example: If the input is 100 the output is 10.00 Example: If the input is -55 the output is Exception: Negative input for square root entered. Example: If…in c # i need to Write the program BookExceptionDemo for the Peterman Publishing Company. Create a BookException class that is instantiated when a Book’s price exceeds 10 cents per page and whose constructor requires three arguments for title, price, and number of pages. Create an error message that is passed to the Exception class constructor for the Message property when a Book does not meet the price-to-pages ratio. Next, create a Book class that contains fields for title, author, price, and number of pages. Include properties for each field. Throw a BookException if a client program tries to construct a Book object for which the price is more than 10 cents per page. Finally, using the Book class, create an array of five Books. Prompt the user for values for each Book. To handle any exceptions that are thrown because of improper or invalid data entered by the user, set the Book’s price to the maximum of 10 cents per page. At the end of the program, display all the entered, and…in C# i need to Write the program BookExceptionDemo for the Peterman Publishing Company. Create a BookException class that is instantiated when a Book’s price exceeds 10 cents per page and whose constructor requires three arguments for title, price, and number of pages. Create an error message that is passed to the Exception class constructor for the Message property when a Book does not meet the price-to-pages ratio. For example, an error message: For Goodnight Moon, ratio is invalid. ...Price is $12.99 for 25 pages. Next, create a Book class that contains fields for title, author, price, and number of pages. Include properties for each field. Throw a BookException if a client program tries to construct a Book object for which the price is more than 10 cents per page. Finally, using the Book class, create an array of five Books. Prompt the user for values for each Book. To handle any exceptions that are thrown because of improper or invalid data entered by the user, set the Book’s…
- 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!Use nested (or inner) functions, closure and decorators to write menu driven program to find and print area and perimeter of a circle. Add a decorator function to validate the input radius to check less than zero or not. If the radius is less than or equal to zero, raise an exception.Solve the problem in C++ (HexFormatException)Implement the hex2Dec function in Programming Exercise 16.1 to throw a HexFormatException if the string is not a hex string .Define a custom exception class named HexFormatException. Write a test program that prompts the user to enter a hex number as a string and displays the number in decimal. If the function throws an exception, display "Not a hex number".
- Identify what is wrong with the following code and what needs to be changed inorder for it to run:def setAge(value):self.__age = value if(value < 21): raise Exception("Age must be greater than 21")ANSWER IN JAVA Standard Output: Enter·side·length·of·square:Side·length·must·be·greater·than·0.↵ Define the class InvalidSideException, which inherits from the Exception class. Also define a Square class, which has one method variable -- an int describing the side length. The constructor of the Square class should take one argument, an int meant to initialize the side length; however, if the argument is not greater than 0, the constructor should throw an InvalidSideError. The Square class should also have a method getArea(), which returns the area of the square.Create a Driver class with a main method to test your classes. Your program should prompt the user to enter a value for the side length, and then create a Square object with that side length. If the side length is valid, the program should print the area of the square. Otherwise, it should catch the InvalidExceptionError, print "Side length must be greater than 0.", and terminate the program.Can i get solution for b a. Create a CourseException class that extends Exception and whose constructor receives a String that holds a college course’s department (for example, CIS), a course number (for example, 101), and a number of credits (for example, 3). Save the file as CourseException.java. Create a Course class with the same fields and whose constructor requires values for each field. Upon construction, throw a CourseException if the department does not consist of three letters, if the course number does not consist of three digits between 100 and 499 inclusive, or if the credits are less than 0.5 or more than 6. Save the class as Course.java. Write an application that establishes an array of at least six Course objects with valid and invalid values. Display an appropriate message when a Course object is created successfully and when one is not. Save the file as ThrowCourseException.java. 3.b. Modify the CourseException class to extend RuntimeException class and identify the…