Question: JAVA ONLY. Double down on data types Write a program that declares the following: A string variable named myResponse An int variable named myNumber Have

JAVA ONLY.

  1. Double down on data types

Write a program that declares the following:

  • A string variable named myResponse

  • An int variable named myNumber

Have your program ask, What number should I double?

Store the result inside of the myResponse variable.

Paste the following snippit into your code after storing the users response inside of myResponse:

// Convert from String data type to an int data type

myNumber = Integer.parseInt(myResponse);

// Lets double our response by adding it to itself

myResponse = myResponse + myResponse;

myNumber = myNumber + myNumber;

/*

* Print out the results of both operations like so:

* My Response variable:

* My Number variable:

*/

System.out.print("My Response variable: ");

System.out.println(myResponse);

System.out.print("My Number variable: ");

System.out.println(myNumber);

Run your code and see that the two results are different. Try your program with different numbers and see if behaves how you expect. Leave a multiline comment below this code explaining why you think the two outputs are different.

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!