This preview shows page 1. Sign up to view the full content.
Unformatted text preview: ype boolean is a special variable type to declare so-called
boolean variables. Boolean variables can be given only two values: true and false. We
shall study these variables in more detail when we encounter them in some example programs.
Some other programming languages (e.g. C++ and C#) have "unsigned" integral
variable types. In such variables it is possible to store only non-negative whole numbers.
These variable types are not available in the Java programming language. Exercises with program Game.java
Exercise 5-1. Modify the program so that it always loses the game by presenting a number which is one
smaller than the number given by the user. With operator - it is possible to perform subtractions
in Java. Exercise 5-2. Modify the program so that it prints three numbers that are larger than the number given by the
user. For example, if the user types in 144, the program must print 145, 146, and 147. 106 Chapter 5: Variables and other basic elements in Java programs A variable of type byte needs only a single byte of...
View Full Document
This document was uploaded on 01/20/2014.
- Winter '14