Chapter 4

7 Pages
Unlock Document

Information Technology Management
ITM 200
Vikraman Baskaran

Chapter 4 Inputs and strings 4.1 Adding two numbers If you wish to write a program which adds together 2 numbers There some initial questions which you should ask in order to clarify what is required o What do you mean by numbers? There is more than 1 type of number in Java Integers or floating point numbers These are stored differently in Java You can use the + operator to add either but you cannot store floating point numbers in integer-type variables o Can the numbers be negative, or will they always be positive? o What do you do with the answer? Write it into a file on the hard disk? Write it on the screen in a dialog box? Write it on the screen in the command window? Use it in a further calculation? o Will you use a graphical user interface (GUI) or command line input and output? Let us suppose that you are going to read in 2 integers and write their sum on the screen using methods from JOptionPane for input and output The plan Ask the user to enter an integer Read the number in and store it in a variable Ask the user for second integer Read it in and store it in a variable Add together the 2 numbers and store the result in a variable
More Less

Related notes for ITM 200

Log In


Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.