chapter_5_beginning_javabook

Nextint 1 systemoutprint n you typed in

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r_from_keyboard = one_larger_integer integer_from_keyboard = keyboard.nextInt() ; + 1; System.out.print( "\n You typed in " + integer_from_keyboard + "." + "\n My number is " + one_larger_integer + "." + "\n Sorry, you lost. I won. The game is over.\n") ; It is possible to output many types of data in a single call to method System.out.print(). Here the values of the integer variables are dis- played between strings of characters given inside double quotes. Operator + is placed between different types of data. The + operator converts the numerical values stored in the variables to character strings, and joins these character strings to the other character strings given inside double quotes. A semicolon (;) terminates the entire statement. Game.java - 1 - 1. The action statements of the program. D:\javafiles2>java Game This program is a computer game. Please, type in an integer in the range 1 ... 2147483646 : 1234 You typed in 1234. My number is 1235. Sorry, you lost. I won. T...
View Full Document

Ask a homework question - tutors are online