What output is produced by the following code?int waitTime = 46;try{cout << "Try block entered.\n";if (waitTime > 30)throw waitTime;cout << "Leaving try block.\n";}catch(int thrownValue){cout << "Exception thrown with\n"<< "waitTime equal to " << thrownValue << endl;}cout << "After catch block" << endl;
Q: Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the…
A: EXPLANATION This issue is due to the “line number 6”. You are using “\n”, at the end of the…
Q: QUESTION 8 What happens when the following code is executed? void function2(){ throw…
A: An exception is thrown by function2() and caught by function 1() Explanation:- As from the above…
Q: he following snippet of code inputs an integer and outputs it: int num=0; Scanner kbd = new…
A: import java.util.Scanner; public class test { public static void main(String[] args) { int…
Q: Mr. Ahmed wants to check whether the Employee ID and GSM number entered by the Employee to register…
A: Code: import java.util.Scanner; class MyClass { public static void main(String[] args) { Scanner…
Q: PLZ help with the follwoing IN JAVA Suppose that statement2 causes an exception in the following…
A: 1. No 2. No 3. Yes
Q: The following snippet of code inputs an integer and outputs it: int num=0; Scanner kbd = new…
A:
Q: 1 # Split input into 2 parts: name and age 2 parts = input ().split() 3 name = parts[0] while name…
A: 1) Program in question reads name and age from user and display name and age where age in…
Q: What will be the output of the following program? public static void main(String args[]){ int i=0,…
A: The above-given program will generate the class, interface or enum expected error which is a…
Q: Exercise # 2 Write a program that asks the user to input a set of floating-point values. When the…
A:
Q: The given program reads a list of single-word first names and ages (ending with -1), and outputs…
A: The given program reads a list of single-word first names and ages (ending with -1), and outputs…
Q: he following line, allows C++ to throw an exception whenever the failbit is set.…
A: #include<iostream> #include<limits> using namespace std; int main() { int a;…
Q: Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the…
A: The try block lets you test a block of code for errors. The except block lets you handle the error.
Q: Which of the following statements accurately describe the C++ code except below ? int* arr =…
A: According to the information given:- I tried the above code to run. It is compiling with out error.
Q: Is the following code legal? What exception types can be caught by the following handler? Identify…
A: Please upvote/like. I am providing you the correct answer below.
Q: MethodX calls method Y and methodY calls method Z in a programme, and methodZ will throw a…
A: The answer is d) Indeed, if methodZ's header contains a ClassCastException.
Q: This is the question - Write an application that throws and catches an ArithmeticException when…
A: Answer: 1) take an integer input from the user 2) if the input number is positive then print the…
Q: There is no maximum number of arguments that may be used inside a catch block since this kind of…
A: Intro Handling of exceptions: A common kind of error that a programmed could encounter is a logical…
Q: Write a square_root() function that takes a number and returns the square root. The square_root()…
A: given: Write a square_root() function that takes a number and returns the square root. The…
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: This lab will exercise your understanding of some of the concepts covered in Chapter 14: exception…
A: #include <iostream>using namespace std;int main(){ int feet = 0,inch= 0; while(true)…
Q: What outcomes are possible in the event that an exception is thrown outside of a try block?
A: An exception is thrown outside of a try block, control is passed out of the block that threw the…
Q: Given the following code, the output is __. try { Integer number = new Integer("1");…
A: EXPLANATION: When running Java code, several mistakes might occur, including programmer errors,…
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: Identify what is wrong with the following code and what needs to be changed in order for it to run:…
A: Here self is not defined so remove self.__age=value
Q: After Exception of following statements: int x, y; char ch; cin ignore (7,'2'); cin.get(ch); cin…
A: ignore() function is used which is used to ignore or clear one or more characters from the input…
Q: #include #include using namespace std; int main() { cout 5) throw s.size(); if…
A: Complete the following catch block so that the program catches the correct types of exceptions
Q: I need to know how to do this in python: Write a program that calculates an adult's fat-burning…
A: Given: I need to know how to do this in python: Write a program that calculates an adult's…
Q: QUESTION 3 an exception may occur within method A, O Hethod A must define the exception as its…
A: Exception Handling: The exception handling makes sure that the continuous flow of the program…
Q: 10. What happens when 100 divided by 0? A. throws an exception. В. 1 C.0 D. uncertain
A: answer is A throws an exception explanation : It will throws an exception because division by…
Q: Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the…
A: Here I have defined the function get_age(). In this function, I have taken input from the user and…
Q: Write a program that will ask user to enter CNIC number without dashes. It must throw exception if…
A: #include<iostream>#include <typeinfo>using namespace std;bool check_number(long s) {…
Q: Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the…
A: Python program to calculate fat burning heart rate . In this python code expection hadling also…
Q: Write a program that prompts the user to enter a person's date of birth in numeric form such as…
A: #include <iostream> #include <exception> #include <sstream> //convert…
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: uppose that statement2 causes an exception in the following statement: 1 try { 2 statement1; 3…
A: Lets see the solution.
Q: 4.) How many times is the println statement executed? for (int i = 0; i < 10; i++) for (int j = 0;…
A: 4.) Defined the given code println statement executed
Q: a. What is the output of the following code? And why? try{ int x = 2; tnt y = 0; int z = x/yi…
A: a. Given program: import java.util.*; class Main { public static void main(String[] args) {…
Q: The given program reads a list of single-word first names and ages (ending with -1), and outputs…
A: PROGRAM CODE: #include <iostream>#include <vector>using namespace std; int main() {…
Q: Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the…
A: The class type of ve is ValueError. Convert the ve to a string via str() function. Use the addition…
Q: Write a program SEGMENT that does the following: Asks the user for his/her birthday using 2…
A: Program code: //include the required header files #include <iostream> #include <cmath>…
Q: Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the…
A: Please find the answer below :
Q: The following line, allows C++ to throw an exception whenever the failbit is set. |…
A: Algorithm : doubleIt function Step 1 : using cin.exceptions() to throw an exception. Step 2 :…
Q: The following code is causing an exception during the runtime. class test { public static void…
A: Here first we create object of String and Random, assign them to Object class reference variable.…
Q: 1. What type of exception does the following code raise? print(3+"test") 2. What type of…
A: What type of exception does the following code raise? print(3+"test") Error:- Unsupported operand…
Q: If we are trying to use try statement to catch exceptions thrown when user doesn't provide the…
A: In "try" block, the user has been prompted to enter an integer input. If the user enters an expected…
What output is produced by the following code?
int waitTime = 46;
try
{
cout << "Try block entered.\n";
if (waitTime > 30)
throw waitTime;
cout << "Leaving try block.\n";
}
catch(int thrownValue)
{
cout << "Exception thrown with\n"
<< "waitTime equal to " << thrownValue << endl;
}
cout << "After catch block" << endl;
Step by step
Solved in 2 steps with 1 images
- use C++ programing language Write a program that prompts the user to enter a person's date of birth in numeric form such as 8-27-1980. The program then outputs the date of birth in the form: August 27, 1980. Your program must contain at least two exception classes: invalidDay and invalidMonth. If the user enters an invalid value for day, then the program should throw and catch an invalidDay object. Similar conventions for the invalid values of month and year. (Note that your program must handle a leap year.)There is no maximum number of arguments that may be used inside a catch block since this kind of block does not have a parameter restriction.There is no limit on the amount of arguments in a catch block.
- There is no maximum number of arguments that may be used inside a catch block since this kind of block does not have a restriction.PYTHON: A pedometer treats walking 2,000 steps as walking 1 mile. Write a steps_to_miles() function that takes the number of steps as a parameter and returns the miles walked. The steps_to_miles() function throws a ValueError object with the message "Exception: Negative step count entered." when the number of steps is negative. Complete the main() program that reads the number of steps from a user, calls the steps_to_miles() function, and outputs the returned value from the steps_to_miles() function. Use a try-except block to catch any ValueError object thrown by the steps_to_miles() function and output the exception message. Output each floating-point value with two digits after the decimal point, which can be achieved as follows:print('{:.2f}'.format(your_value)) Ex: If the input of the program is: 5345 the output of the program is: 2.67 Ex: If the input of the program is: -3850 the output of the program is: Exception: Negative step count entered.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…
- PARTICIPATION ACTIVITY Arrange the following lines to make a program that determines when the number of people in a restaurant equals or exceeds 10 occupants. The program continually gets the number of people entering or leaving the restaurant. Ex: 2 means two people entered, and -3 means three people left. After each input, the program outputs the number of people in the restaurant. Once the number of people in the restaurant equals or exceeds 10, the program exits. If an Input MismatchException exception occurs, the program should get and discard a single string from input. Ex: The input "2 abc 8" should result in 10 occupants. Not all lines are used in the solution. How to use this tool ✓ Unused totalNumPeople += scnr.nextInt (); while (totalNumPeople < maxNumPeople) { } } 11.1.5: Handling input exceptions: restaurant max occupancy tracker. catch { try { catch (InputMismatchException e) { scnr .nextLine(); scnr.next(); System.out.println("Error"); } System.out.println("Occupancy:…No restriction exists on the number of arguments permitted in a catch block.DIRECTION: Using Java as program language Create a simple program for a quiz bee with a class named QuizBee. The program shall:o Contain an array of 15 multiple choice questions with three (3) choiceseach and;o Require the user to choose among A, B or C.o Note: Cases are ignored. Lowercase letters are acceptable (a,b, or c) Create a try-catch structure to handle three (3) exceptions. These are when theuser inputs the following:o An invalid letter (not A, B or C)o A number or any special character.o Blank (no answer). Prompt the user to answer again if any of the three (3) exceptions is thrown. Display the score, number of incorrect answers and corrects answers.
- C++ programming D.S.Malik 14-5 Write a program that prompts the user to enter a person’s date of birth in numeric form such as 8-27-1980. The program then outputs the date of birth in the form: August 27, 1980. Your program must contain at least two exception classes: invalidDay and invalidMonth. If the user enters an invalid value for day, then the program should throw and catch an invalidDay object. Follow similar conventions for the invalid values of month and year. (Note that your program must handle a leap year.)Python Code: Write a function that takes a single number as an argument: 1) This function should then check whether a number is an even number (2,4,6,8) and raise an exception if otherwise 2) Call this function with an uneven number first without catching the exception and then with catching the exception and printing a warning to the user afterwards Bonus: Do the same as the above but instead implement your solution for prime numbers and call the function with a non-prime numbermain.py Load default template... 1 # Define your method here 2 3 if main ': name 4 # Type your code here.