The names of the variables are integerfromkeyboard

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: names of the variables are integer_from_keyboard and one_larger_integer. The variables are referred to with these names later in the program. (c) Kari Laitinen import java.util.* ; class Game { public static void main( String not_in_use ) { Scanner keyboard = new Scanner( ) ; int int integer_from_keyboard ; one_larger_integer ; System.out.print( "\n This program is a computer game. Please, type in " + "\n an integer in the range 1 ... 2147483646 : " ) ; integer_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") ; } } This line of source code reads an integer from the keyboard and stores the read integer into variable integer_from_keyboard. The execution of the program stays on this line until the user of the program has entered an integer. The integer is read by the nextInt...
View Full Document

This document was uploaded on 01/20/2014.

Ask a homework question - tutors are online