Big Java Late Objects
2nd Edition
ISBN: 9781119330455
Author: Horstmann
Publisher: WILEY
Textbook Question
Chapter 2, Problem 1RE

Write declarations for storing the following quantities. Choose between integers and floating-point numbers. Declare constants when appropriate.

1. a. The number of days per week
2. b. The number of days until the end of the semester
3. c. The number of centimeters in an inch
4. d. The height of the tallest person in your class, in centimeters

a.

Expert Solution

### Explanation of Solution

Declaration for the first statement:

• The given statement is “The number of days per week”.
• Totally, there are seven days in a week and there is no change of days in a week.
• Hence, the number of days in a week is fixed forever.
• The declaration for storing the number of days in a week is as follows:

/* Declaration for storing the number of days in a week */

public static final int DAYS_PER_WEEK = 7;

b.

Expert Solution

### Explanation of Solution

Declaration for the second statement:

• The given statement is “The number of days until the end of the semester”.
• The number of days in a semester varies from time to time and the days may either increase or decrease based on the semester time-table.
• Hence, the number of days in a semester is an integer variable.
• The declaration for storing the number of days in a semester is as follows:

/* Declaration for storing the number of days in a semester */

public int daysInSemester;

c.

Expert Solution

### Explanation of Solution

Declaration for the third statement:

• The given statement is “The number of centimeters in an inch”.
• The number of centimeters in an inch is a fixed type of float value.
• The declaration for storing the number of centimeter in an inch is as follows:

/* Declaration for storing the number of centimeters in an inch */

public static final float CENTIMETERS_IN_INCH = 2.54;

d.

Expert Solution

### Explanation of Solution

Declaration for the fourth statement:

• The given statement is “The height of the tallest person in your class, in centimeters”.
• The height of the tallest person in a class is a float value since height contains decimal values.
• The height of a person varies over time.
• Hence, the height of a person is not fixed and it is float type value.
• The declaration for storing the height of the tallest person in a class is as follows:

/* Declaration for storing the height of the tallest person in a class*/

public float tallestHeight;

### Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
05:20
Students have asked these similar questions
Declare int variables x and y. Initialize x to 25 and y to 18.
15. Speed Conversion ChartYour friend Amanda, who lives in the United States, just bought an antique European sports car. The car’s speedometer works in kilometers per hour. The formulafor converting kilometers per hour to miles per hour is:MPH = KPH * 0.6214In the formula, MPH is the speed in miles per hour and KPH is the speed in kilometersper hour. Amanda is afraid she will get a speeding ticket, and has asked you to write aprogram that displays a list of speeds in kilometers per hour with their values convertedto miles per hour. The list should display the speeds from 60 kilometers per hourthrough 130 kilometers per hour, in increments of 5 kilometers per hour. (In otherwords, it should display 60 kph, 65 kph, 70 kph, and so forth, up through 130 kph.)   made in visual studio 2017
Variables of type single occupy half the memory of variables of type double, but they have lower precision and a more limited range. O True O False
• Copyright, Community Guidelines, DSA & other Legal Resources: Learneo Legal Center
• bartleby, a Learneo, Inc. business