Java Reference
In-Depth Information
EX 3.11 Write code statements that prompt for and read a double value
from the user, and then print the result of raising that value to
the fourth power. Output the results to three decimal places.
EX 3.12 Write a declaration for an enumerated type that represents the
days of the week.
Programming Projects
Visit www.myprogramminglab.com to complete many of these Programming
Projects online and get instant feedback.
PP 3.1
Write an application that prompts for and reads the user's first
and last name (separately). Then print a string composed of
the first letter of the user's first name, followed by the first five
characters of the user's last name, followed by a random number
in the range 10 to 99. Assume that the last name is at least five
letters long. Similar algorithms are sometimes used to generate
usernames for new computer accounts.
PP 3.2
Write an application that prints the sum of cubes. Prompt for
and read two integer values and print the sum of each value
raised to the third power.
PP 3.3
Write an application that creates and prints a random phone
number of the form XXX-XXX-XXXX. Include the dashes in
the output. Do not let the first three digits contain an 8 or 9
(but don't be more restrictive than that), and make sure that the
second set of three digits is not greater than 742. Hint: Think
through the easiest way to construct the phone number. Each
digit does not have to be determined separately.
PP 3.4
Write an application that reads the ( x,y ) coordinates for two
points. Compute the distance between the two points using the
following formula:
Distance
=
( x 2 - x 1 ) 2 + ( y 2 - y 1 ) 2
PP 3.5
Write an application that reads the radius of a sphere and prints
its volume and surface area. Use the following formulas. Print
the output to four decimal places. r represents the radius.
VideoNote
4
Developing a solution
of PP 3.5.
r 3
Volume
=
3 p
r 2
Surface Area
=
4
p
Search WWH ::




Custom Search