Question: In your introduction to Java, you probably used the scanner class to facilitate reading keyboard input. You may have used such Scanner methods as readLine

 In your introduction to Java, you probably used the scanner class

In your introduction to Java, you probably used the scanner class to facilitate reading keyboard input. You may have used such Scanner methods as readLine readInt 0. In this exercise, we use this class to do a slightly sophisticated version of a simple task. and Here's the task: read in two numbers, then compute and print their sum. A run of your program would look something like this (user's text in red): two nunbers The sum of and 5 is 9 However, there is one small twist: your program should let the user silently decide whether to enter numbers as integers or floating-point numbers (or, in Java terms, as int or as double ). And then your program should calculate and display the sum depending on the type of the user's input. So your program should also run like this: Enter tvo nunbers: 4.2 5-45 The sun of 4.2 and 5.45 1s 9.65 Of course, your program should be able to deal with 'mixed types: Enter two nunbers: 5 17.3 The sun of 5 and 17.3 is 22.3

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!