*expand_more*

*expand_more*

*format_list_bulleted*

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

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

**a.**

### 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.**

### 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.**

### 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.**

### 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?

*schedule*05:20

# Chapter 2 Solutions

Big Java Late Objects

# Additional Engineering Textbook Solutions

Computer Systems: A Programmer's Perspective (3rd Edition)

Data Mining for Business Analytics: Concepts, Techniques, and Applications with XLMiner

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

Starting Out with Java: Early Objects (6th Edition)

Java How To Program (Early Objects)

Problem Solving with C++ (9th Edition)

- Show the value of x after each of the statements is performed: x = fabs(0.0);
*arrow_forward*Indicate whether the argument is valid or invalid. For valid arguments, prove that the argument is valid using a truth table. For invalid arguments, give truth values for the variables showing that the argument is not valid.*arrow_forward*Filling the Pool (Deprecated) Write a program that calculates the time neccessary to completely fill an empty pool with water. We will assume that the pool is rectangular and the depth is uniform. All input values in this program will be integers. Prompt the user to enter the pool dimensions - length, width, and depth (unit: feet) - as well as the rate at which water can be put into the pool (unit: gallons per minute). Using these values, calculate and display the time (in minutes) needed to fill the pool from completely empty to completely full. Note: you should calculate the volume of the pool (as cubic feet) and then determine the rate (in cubic feet per minute) that water can be put into the pool. Assume that there are 7.48 gallons in one cubic foot. Your program should run like the examples shown below: Enter pool dimensions Length: 10 Width: 8 Depth: 7 Water entry rate: 14 The pool will fill completely in 299.2 minutes*arrow_forward* - Write the statements to sum the odd integers between 1 and 99 by using a for statement. Assume that the integer variables sum and count have been defined earlier. 2.
*arrow_forward*1) Simple Calculator: In Python, implement a simple calculator that does the following operations: summation, subtraction, multiplication, division, sqrt, power, natural log and abs. a) Follow the instructions below: To work with the calculator, the user is asked to enter the first number, then the operation, and finally, a second number if required. Your code has to recognize the need for the second number and ask for it if required. After performing one operation, the calculator prints the output of the operation. After performing one operation, the calculator must not exit. It has to start again for the next operation. The calculator will be closed if the user writes 'e' as any input. Use functions to perform the operations and the appropriate conditions to prevent common errors such as entering characters as one of the numbers etc. b) Run your code and provide the results for at least one example per operation. - -*arrow_forward*Identify the invalid variable name from the following given variables. a. Amount45 b. 45amount C. Amount_45 d. _45amount*arrow_forward* - # given a radius, find the area of a circle # use value of pi as 3.1415 def get_area_circle(r): """ what it takes radius of a circle (any positive real number) what it does: computes the area of a circle given a radius, find the area of a circle area = pi*r2 (pi times r squared) what it returns area of a circle. Any positive real number (float) """ # your code goes in here
*arrow_forward*“As one variable goes up, the other variable goes down” is a description of:*arrow_forward*:Q3: Answer the following Determine the value, true or false, of each of the following Boolean expressions, assuming that the value of the variable count is 5 and the value of the variable limit is -1. Give your answer as one of the values true or false. a. (count = ((0 c. (limit/count) > 7) || (limit < 20) IMI r263 LAlas Google la e 1ajall lals Juayl pae*arrow_forward* - Financial application: compute future apartment rent) Suppose that the rent for an apartment is $1000 thisyear and increases 3% every year. Write a program that computes the rent in five years and the total rent forone year starting five years from now.
*arrow_forward*x = 9 ; y = x++ What are the values of x and y after the two statements execute? X = y =*arrow_forward*You are required to create a conversion program. First ask the user his choice and then convert. Conversion from Pound to Kg. (1 Pound = 0.453 Kg) Conversion from Feet to centimeter (1 Foot = 30.48 cm) Convert Hours & minutes in Days*arrow_forward*

*arrow_back_ios*

*arrow_forward_ios*

- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,