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
WITCHER [35]
3 years ago
9

Write a program that prompts the user to read two integers and displays their sum . if anything but an integer is passed as inpu

t, your program should catch the inputmismatchexception that is thrown and prompt the user to input another number by printing "please enter an integer ."
Mathematics
1 answer:
natka813 [3]3 years ago
4 0
<span>The Java code below will ask for two integers and display the sum. If a non-integer is submitted the code will ask again. The break is used to exit the while true loop indicating that no-errors had occurred and two numbers were added. System.out.print("Please insert two integers and this will display the sum."); int numOne; int numTwo; while (True) { try{ System.out.print("Integer Number One? "); numOne = input.nextInt(); System.out.print("Integer Number Two? "); numTwo = input.nextInt(); System.out.print("The Sum Is: " + (numOne + numTwo)); break; } catch (InputMismatchException e) { System.out.print("please enter an integer ."); } }</span>
You might be interested in
What is the value of x? Enter your answer in the box.<br><br><br><br> i need to post graph
kondaur [170]
2x + 2 = 3x - 52
x = 54
4 0
3 years ago
Answer it answer it answer it
Troyanec [42]

Answer:

22.5

Step-by-step explanation:

cause

8 0
3 years ago
Read 2 more answers
ALGEBRA Find the value of x in each figure.<br><br> HELP ASAP
yKpoI14uk [10]

Answer:

x=17

Step-by-step explanation:

4 0
3 years ago
Read 2 more answers
Parking in a student lot costs $2 for the first half hour and $1.75 for each hour thereafter. A partial hour is charged the same
Masteriza [31]

An easier way to think of this problem is just keep adding for each additional hour: 


0.5 hours --> $2 

1.5 hrs --> $3.75 

2.5 hrs --> $5.50 

3.5 hrs --> $7.25 


and since you can only spend $7, the maximum time is 2.5 hours

3 0
3 years ago
Read 2 more answers
Solve these recurrence relations together with the initial conditions given. a) an= an−1+6an−2 for n ≥ 2, a0= 3, a1= 6 b) an= 7a
8_murik_8 [283]

Answer:

  • a) 3/5·((-2)^n + 4·3^n)
  • b) 3·2^n - 5^n
  • c) 3·2^n + 4^n
  • d) 4 - 3 n
  • e) 2 + 3·(-1)^n
  • f) (-3)^n·(3 - 2n)
  • g) ((-2 - √19)^n·(-6 + √19) + (-2 + √19)^n·(6 + √19))/√19

Step-by-step explanation:

These homogeneous recurrence relations of degree 2 have one of two solutions. Problems a, b, c, e, g have one solution; problems d and f have a slightly different solution. The solution method is similar, up to a point.

If there is a solution of the form a[n]=r^n, then it will satisfy ...

  r^n=c_1\cdot r^{n-1}+c_2\cdot r^{n-2}

Rearranging and dividing by r^{n-2}, we get the quadratic ...

  r^2-c_1r-c_2=0

The quadratic formula tells us values of r that satisfy this are ...

  r=\dfrac{c_1\pm\sqrt{c_1^2+4c_2}}{2}

We can call these values of r by the names r₁ and r₂.

Then, for some coefficients p and q, the solution to the recurrence relation is ...

  a[n]=pr_1^n+qr_2^n

We can find p and q by solving the initial condition equations:

\left[\begin{array}{cc}1&1\\r_1&r_2\end{array}\right] \left[\begin{array}{c}p\\q\end{array}\right] =\left[\begin{array}{c}a[0]\\a[1]\end{array}\right]

These have the solution ...

p=\dfrac{a[0]r_2-a[1]}{r_2-r_1}\\\\q=\dfrac{a[1]-a[0]r_1}{r_2-r_1}

_____

Using these formulas on the first recurrence relation, we get ...

a)

c_1=1,\ c_2=6,\ a[0]=3,\ a[1]=6\\\\r_1=\dfrac{1+\sqrt{1^2+4\cdot 6}}{2}=3,\ r_2=\dfrac{1-\sqrt{1^2+4\cdot 6}}{2}=-2\\\\p=\dfrac{3(-2)-6}{-5}=\dfrac{12}{5},\ q=\dfrac{6-3(3)}{-5}=\dfrac{3}{5}\\\\a[n]=\dfrac{3}{5}(-2)^n+\dfrac{12}{5}3^n

__

The rest of (b), (c), (e), (g) are solved in exactly the same way. A spreadsheet or graphing calculator can ease the process of finding the roots and coefficients for the given recurrence constants. (It's a matter of plugging in the numbers and doing the arithmetic.)

_____

For problems (d) and (f), the quadratic has one root with multiplicity 2. So, the formulas for p and q don't work and we must do something different. The generic solution in this case is ...

  a[n]=(p+qn)r^n

The initial condition equations are now ...

\left[\begin{array}{cc}1&0\\r&r\end{array}\right] \left[\begin{array}{c}p\\q\end{array}\right] =\left[\begin{array}{c}a[0]\\a[1]\end{array}\right]

and the solutions for p and q are ...

p=a[0]\\\\q=\dfrac{a[1]-a[0]r}{r}

__

Using these formulas on problem (d), we get ...

d)

c_1=2,\ c_2=-1,\ a[0]=4,\ a[1]=1\\\\r=\dfrac{2+\sqrt{2^2+4(-1)}}{2}=1\\\\p=4,\ q=\dfrac{1-4(1)}{1}=-3\\\\a[n]=4-3n

__

And for problem (f), we get ...

f)

c_1=-6,\ c_2=-9,\ a[0]=3,\ a[1]=-3\\\\r=\dfrac{-6+\sqrt{6^2+4(-9)}}{2}=-3\\\\p=3,\ q=\dfrac{-3-3(-3)}{-3}=-2\\\\a[n]=(3-2n)(-3)^n

_____

<em>Comment on problem g</em>

Yes, the bases of the exponential terms are conjugate irrational numbers. When the terms are evaluated, they do resolve to rational numbers.

6 0
3 years ago
Other questions:
  • Solve for x : 2x^2+4x-16=0
    6·2 answers
  • How to make number set 11 to 15
    14·1 answer
  • A multiple regression model has ___
    15·1 answer
  • The answer is b. I didn't see it on here so helping look a picture​
    5·1 answer
  • What is the sign of -567.45 + 567.45? Choose 1 answer: Choose 1 answer: (Choice A) A Positive (Choice B) B Negative (Choice C) C
    5·2 answers
  • A man has 30 coins, which are all dimes or nickels. Their combined value is $2.10. How many coins of each kind does he have? Let
    15·2 answers
  • ANSWER BOTH QUESTIONS FOR BRAINLIEST!
    6·2 answers
  • Can U PLEASE HELP ME
    9·1 answer
  • Triangle DEF is a right triangle. The length of the legs are 7 cm and 10 cm, how long is the hypotenuse? Round to the nearest te
    7·2 answers
  • Maya spent her allowance on playing an arcade game a few times and riding the Ferris wheel more than once.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!