1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
-Dominant- [34]
3 years ago
11

The 'parseInt' method of the 'Integer' class throws a 'NumberFormatException' when it is passed a String argument that it cannot

convert to an int. Given the String variable s (which has already been assigned a value), write the code needed to convert the value in s assigning the result to the integer variable i If a NumberFormatException is thrown, i should be assigned the value -1.
Computers and Technology
1 answer:
vekshin13 years ago
3 0

Answer:

Following are the code in the java language  

try // try block

{

i = Integer.parseInt(s); // converting into the integer  

}  

catch (NumberFormatException e) // catch block

{

i = -1; // initialized i to -1.

}

Explanation:

Following is the description of code.

  • Create a try block in that clock we convert the variable "s" into the integer by using the function  Integer.parseInt and storing in the variable "i".
  • if try block gives an error the console is directly going  in the second we create a catch block for that try block In this block we initialized the variable  i to -1.
You might be interested in
Consider the following code segment:
horrorfan [7]

Answer:

13333333333333333333333fv mvfdmv mfv fmv f mf vmf f vfmvnfmvnmnvmfnvmnvmnv3Explanation:

6 0
3 years ago
David plays racing games on his way to work. He uses the analog stick to navigate his vehicle through other artificial intellige
Sphinxa [80]

Answer: David is most likely playing on Handheld.

Explanation: You can infer that he is playing on a handheld due to the fact that he is playing this game on his way to work, and the fact that he is controlling the game using an analog stick. Because of this, you can assume that what he is playing on needs to be portable, making it likely he is using a handheld.

7 0
3 years ago
Read 2 more answers
simplify the expression below and state the value of m for which the simplified expression is not defined 2m² + m - 15/ m² - 9​
motikmotik

Answer:

  • The simplified expression is: \frac{2m-5}{m-3}
  • The simplified expression is undefined for m=3

Explanation:

The given expression is:

\frac{2m^2+m-15}{m^2-9}

The numerator can be siplified by using factorization and denominator will be simplified using the formula

a^2-b^2 = (a+b)(a-b)

So,

= \frac{2m^2+6m-5m-15}{(m)^2-(3)^2}\\=\frac{2m(m+3)-5(m+3)}{(m-3)(m+3)}\\=\frac{(2m-5)(m+3)}{(m-3)(m+3)}\\=\frac{2m-5}{m-3}

A fraction is undefined when the denominator is zero. In order to find the value of m on which the simplified fraction will be undefined we will put denominator equal to zero.

So,

m-3 = 0 => m = 3

Hence,

  • The simplified expression is: \frac{2m-5}{m-3}
  • The simplified expression is undefined for m=3
7 0
3 years ago
List five application programs you recommend, and write a sentence explaining why.
MArishka [77]

Answer:

hi!

refer attachment

hope it helps!!?

5 0
3 years ago
Write code that prints: Ready! firstNumber ... 2 1 Run! Your code should contain a for loop. Print a newline after each number a
Citrus2011 [14]

Answer:

The program to this question can be describes as follows:

Program:

#include <stdio.h> //defining header file

int main() //defining main method

{

int n,i,x=0; //defining integer variable

printf("Enter a number: "); //print message

scanf("%d",&n); //input value from the user  

printf("%d\n",n); //print input value

for(i=1;i<n;i++)  //loop to count reverse number

{

x=n-i; //calculate value

printf("%d\n",x);  //print value

}

return 0;

}

Output:

Enter a number: 3

3

2

1

Explanation:

  • In the above program, three integer variable "n,i and x" is declared, in which variable n we take input from the user end and the variable i and x is used in the loop to calculate the value in the reverse order.
  • In the next step, a loop is declared, in which the variable x calculates the value in reverse order and uses a print method to print its value.  
5 0
3 years ago
Other questions:
  • You can choose to use a window manager only, and not use a desktop manager.
    8·2 answers
  • When encountering another vessel in darkness or reduced visibility, what do visible red and green lights indicate
    9·1 answer
  • Which of the following represents the TCP/IP four-layer reference model? Group of answer choices Application, Internet, transpor
    11·1 answer
  • The _____ handles the instructions for your computer to start up before the operating system is loaded.
    11·1 answer
  • By default, EC2 instances pull SQS messages from an SQS queue on a FIFO basis.
    6·1 answer
  • Write a program that prompts the user for a name (any String value would work for testing), and print a hello message to the con
    5·1 answer
  • In many cases, a ribbon organizes buttons and options in Select one: a. menus. b. sections. c. toolbars. d. groups.
    9·2 answers
  • Implement a Java program using simple console input &amp; output and logical control structures such that the program prompts th
    15·1 answer
  • Explain what is meant by information technology (IT). Explain what is meant by information systems (IS). Why is it important to
    7·1 answer
  • Linda is searching for a new job. Which information would her potential employers likely review in her social profile?
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!