Java Reference
In-Depth Information
provide carbon-footprint calculators. Test-drive these calculators to determine your carbon foot-
print. Exercises in later chapters will ask you to program your own carbon-footprint calculator. To
prepare for this, use the web to research the formulas for calculating carbon footprints.
1.10 (Test-Drive: Body Mass Index Calculator) Obesity causes significant increases in illnesses
such as diabetes and heart disease. To determine whether a person is overweight or obese, you can
use a measure called the body mass index (BMI). The United States Department of Health and Hu-
man Services provides a BMI calculator at http://www.nhlbi.nih.gov/guidelines/obesity/BMI/
bmicalc.htm . Use it to calculate your own BMI. A forthcoming exercise will ask you to program
your own BMI calculator. To prepare for this, use the web to research the formulas for calculating
BMI.
1.11 (Attributes of Hybrid Vehicles) In this chapter you learned some basics of classes. Now you'll
“flesh out” aspects of a class called “Hybrid Vehicle.” Hybrid vehicles are becoming increasingly
popular, because they often get much better mileage than purely gasoline-powered vehicles. Browse
the web and study the features of four or five of today's popular hybrid cars, then list as many of
their hybrid-related attributes as you can. Some common attributes include city-miles-per-gallon
and highway-miles-per-gallon. Also list the attributes of the batteries (type, weight, etc.).
1.12 (Gender Neutrality) Many people want to eliminate sexism in all forms of communication.
You've been asked to create a program that can process a paragraph of text and replace gender-spe-
cific words with gender-neutral ones. Assuming that you've been given a list of gender-specific
words and their gender-neutral replacements (e.g., replace both “wife” and “husband” with
“spouse,” “man” and “woman” with “person,” “daughter” and “son” with “child”), explain the pro-
cedure you'd use to read through a paragraph of text and manually perform these replacements.
How might your procedure generate a strange term like “woperchild?” You'll soon learn that a more
formal term for “procedure” is “algorithm,” and that an algorithm specifies the steps to be per-
formed and the order in which to perform them. We'll show how to develop algorithms then con-
vert them to Java programs which can be run on computers.
 
Search WWH ::




Custom Search