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?
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_forwardQuestion: Run a program that checks whether the number is even or oddarrow_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 herearrow_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“As one variable goes up, the other variable goes down” is a description of:arrow_forward1) 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
- Do in jupyter notebook! I'm not confident of my code please help me out .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 paearrow_forwardYou are given a list of students’ names and their test scores. Write pseudo code that does thefollowing:a. Calculates the average test scores.b. Determines and prints the names of all the students whose test scores are below the average testscore.c. Determines the highest test score.d. Prints the names of all the students whose test scores are the same as the highest test score.arrow_forward
- 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,