This preview shows page 1. Sign up to view the full content.
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
- Winter '14