Prev | Current Page 238 | Next

Carl Reynolds and Paul Tymann

"Schaum's Outline of Principles of Computer Science"

Store
the dividend and divisor in variables named dividend and divisor before performing the division.
What will be the type of these variables? What will be the type of the result? What is the quotient?
5.2 Write a Java program to compute the area of a circle whose radius is 5. For the value of PI, use 3.14.
Now rewrite your program so that it uses the very precise value of PI available as a static constant in
the Math class that comes with Java. Here is how you use the Math class constant:
double pi = Math.PI;
How much does your result change?
5.3 Write a Java program that prompts the user for a number, and then tells the user whether the number is
an even multiple of 5. Use Scanner to read the number from the user, and use the modulo operator
(%) to decide whether the number is a multiple of 5.
5.4 Write a Java program that asks a user to enter five Strings, one at a time. Have it save the Strings
in an array of strings. Then have the program display the words in reverse order. Use a for, or a
while, or a do while loop to read in the Strings, and another for, while, or do while loop
to print them out.
5.5 Write a Java program that can categorize vehicles based on the number of wheels the vehicle has.


Pages:
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250
meble biurowe noclegi w górach gospodarka maszyna smitha Bank kredyt hipoteczny