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]
2 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]2 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
Two hiking groups made the purchases shown below. What is the cost of each item. GROUP 1: 6 muffins, 12 granola bars, Total=$26.
stepladder [879]

Answer:

Price of each muffin = $1.25

Price of each granola bar = $1.6

Step-by-step explanation:

Group 1:

6 muffins, 12 granola bars

Total money paid = $26.70

Group 2:

8 muffins, 15 granola bars,

Total money paid = $34.00

To find:

Price of each item?

Solution:

Let the price of one muffin = $x

Let the price of one granola bar = $y

As per group 1, the equation can be written as:

6x+12y=26.70\\\Rightarrow x+2y=4.45 .... (1)

As per group 2, the equation can be written as:

8x+15y = 34 .... (2)

Let us use elimination method to solve for x and y.

Multiplying equation (1) with 8 and subtracting (2) from it:

16y-15y = 35.6 - 34\\\Rightarrow y = 1.6

Using equation (1):

x+3.2=4.45\\\Rightarrow x = 1.25

Therefore, the answer is:

Price of each muffin = $1.6

Price of each granola bar = $1.25

7 0
3 years ago
Greek city-states began to form in 800 B.C. and in 200 A.D, Christians began getting persecuted. How many years passed between t
asambeis [7]

Answer: 1000 years

Step-by-step explanation:

-Greek city-states began to form in 800 B.C i.e 800 years Before Christ appearance

- up till 200 A.D i.e 200 years of After Christ disappearance

Hence, the number of years between the time that Greek city-states began to form and the persecution of Christians began is equal to the sum of years Greek city States started formation and Year persecution began

i.e 800 BC + 200 A.D = 1000 Years

Thus, the number of years of that passed was 1000 years

6 0
3 years ago
-36 as a fraction in simplest form
Cerrena [4.2K]

Answer:

-1/2

Step-by-step explanation:


7 0
3 years ago
Read 2 more answers
A hiker climbs a 5-mile trail up a mountain in 2 hours. On the return trip downhill, she walks the same trail and returns to her
Ivahew [28]

Answer:

3.33 miles per hour

Step-by-step explanation:

The total distance traveled by the hiker is 5 * 2 = 10 miles, and the total time travelled is 2 + 1 = 3 hours.

So, to find the average speed of the entire trip, we can use the formula:

distance = speed * time

With distance = 10 and time = 3, we have:

10 = speed * 3

speed = 10/3 = 3.33 miles per hour.

7 0
2 years ago
Greetings. As a beginner, I'm struggling a bit to learn calculus. May I know what is the derivative of x to the power 4 step by
elena-14-01-66 [18.8K]

If you're just starting calculus, perhaps you're asking about using the definition of the derivative to differentiate x^4.

We have

\dfrac{d}{dx} x^4 = \displaystyle \lim_{h\to0} \frac{(x+h)^4 - x^4}h

Expand the numerator using the binomial theorem, then simplify and compute the limit.

\dfrac{d}{dx} x^4 = \displaystyle \lim_{h\to0} \frac{(x^4+4hx^3 + 6h^2x^2 + 4h^3x + h^4) - x^4}h \\\\ ~~~~~~~~ = \lim_{h\to0} \frac{4hx^3 + 6h^2x^2 + 4h^3x + h^4}h \\\\ ~~~~~~~~ = \lim_{h\to0} (4x^3 + 6hx^2 + 4h^2x + h^3) = \boxed{4x^3}

In general, the derivative of a power function f(x) = x^n is \frac{df}{dx} = nx^{n-1}. (This is the aptly-named "power rule" for differentiation.)

3 0
2 years ago
Other questions:
  • Suzanna walked two over seven of a mile in two over five of an hour. What is her unit rate in miles per hour? two sevenths over
    14·1 answer
  • Estimate the domain
    10·2 answers
  • - When Brianna's first CD sold a million copies, her record label
    12·1 answer
  • Fid the log of 0.0007356​
    14·1 answer
  • Notice that the rule for each animal involves counting the number of chirps in different time intervals. For the Brookdale crick
    11·1 answer
  • Determine whether the ordered pair (6, 1) satisfies the equation y = 10 - 4x
    12·1 answer
  • Place the LETTER in the smallest set that contains that value
    5·1 answer
  • Please help will give brainliest!! I have told many people this question and I still can't understand and please read what I say
    8·2 answers
  • Slope-Intercept Form <br><br> -14x+y=7
    6·1 answer
  • I need to find the surface area. it's a cut sphere with a diameter of 14.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!