subject

3.16.1: Exception handling. input20 Type the program's output

import java. util. Scanner;

public class HeartRateExceptHandling {
public static void main(String[] args) {
Scanner scnr = new Scanner(System. in);
int userAge;
int avgMaxHeartRate;

try {
userAge = scnr. nextInt();

if (userAge < 0) {
throw new Exception("Invalid age");
}

// Source: https://www. heart. org/en/healthy-living/fitness
avgMaxHeartRate = 220 - userAge;

System. out. println("Avg: " + avgMaxHeartRate);
}
catch (Exception excpt) {
System. out. println("Error: " + excpt. getMessage());
}
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 19:20
Consider the following code snippet: #ifndef cashregister_h#define cashregister_hconst double max_balance = 6000000.0; class cashregister{public: cashregister(); cashregister(double new_balance); void set_balance(double new_balance); double get_balance() const; private: double balance[12]; }; double get_monthly_balance(cashregister bk, int month); #endifwhich of the following is correct? a)the header file is correct as given.b)the definition of max_balance should be removed since header files should not contain constants.c)the definition of cashregister should be removed since header files should not contain class definitions.d)the body of the get_monthly_balance function should be added to the header file.
Answers: 1
question
Computers and Technology, 23.06.2019 11:30
Which excel file extension stores automated steps for repetitive tasks?
Answers: 1
question
Computers and Technology, 24.06.2019 00:50
Which of the following is not a key player in the sale of travel products?
Answers: 2
question
Computers and Technology, 24.06.2019 06:00
Hey i really need some solving this problem: 1. encrypt this binary string into cipher text: 110000. include in your answer the formula the decoder would use to decrypt your cipher text in the format (coded answer) x n mod (m) = y & 2. decrypt this cipher text into a binary string: 106 you.
Answers: 2
You know the right answer?
3.16.1: Exception handling. input20 Type the program's output

import java. util. Scanne...
Questions
question
Mathematics, 25.09.2021 01:40
question
Mathematics, 25.09.2021 01:40
question
Mathematics, 25.09.2021 01:40
question
Mathematics, 25.09.2021 01:40
question
Mathematics, 25.09.2021 01:40
Questions on the website: 13722359