Java Reference
In-Depth Information
EX 5.14 Write a method called evenlyDivisible that accepts two integer
parameters and returns true if the first parameter is evenly divisi-
ble by the second, or vice versa, and false otherwise. Return false
if either parameter is zero.
EX 5.15 Write a method called isAlpha that accepts a character param-
eter and returns true if that character is either an uppercase or
lowercase alphabetic letter.
EX 5.16 Write a method called floatEquals that accepts three floating
point values as parameters. The method should return true if the
first two parameters are equal within the tolerance of the third
parameter.
EX 5.17 Write a method called isIsosceles that accepts three integer
parameters that represent the lengths of the sides of a triangle.
The method returns true if the triangle is isosceles but not equi-
lateral (meaning that exactly two of the sides have an equal
length), and false otherwise.
EX 5.18 Explain what would happen if the radio buttons used in the
QuoteOptions program were not organized into a ButtonGroup
object. Modify the program to test your answer.
Programming Projects
Visit www.myprogramminglab.com to complete many of these Programming
Projects online and get instant feedback.
PP 5.1
Design and implement an application that reads an integer value
from the user representing a year. The purpose of the program is
to determine if the year is a leap year (and therefore has 29 days
in February) in the Gregorian calendar. A year is a leap year if
it is divisible by 4, unless it is also divisible by 100 but not 400.
For example, the year 2003 is not a leap year, but 2004 is. The
year 1900 is not a leap year because it is divisible by 100, but
the year 2000 is a leap year because even though it is divisible by
100, it is also divisible by 400. Produce an error message for any
input value less than 1582 (the year the Gregorian calendar was
adopted).
PP 5.2
Modify the solution to the previous project so that the user can
evaluate multiple years. Allow the user to terminate the program
using an appropriate sentinel value. Validate each input value to
ensure it is greater than or equal to 1582.
Search WWH ::




Custom Search