Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

ISBN: 133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

=+ What may stay the same?

Answered: 1 week ago