Ask Question
2 May, 17:01

Given decimal variables named length and width that contain the dimensions of a rectangle, write a statement that calculates the rectangle's area and saves the result in a new integer variable named area. (Be sure to cast the result from decimal to integer.)

+1
Answers (1)
  1. 2 May, 18:10
    0
    The code to this question can be defined as follows:

    Code:

    int area = (int) (length * width); / /defining integer variable area that holds calculated value.

    Explanation:

    In the given question it is defined, that two decimal variable "length and width" is defined that holds some decimal value in it, and this question asks to define an integer that holds it calculated value, which can be described as follows:

    In the above code section, an integer variable "area" is defined, which calculates the decimal variable "length and width" multiplication. Inside the area variable, the typecasting is used that converts the decimal value to integer value.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Given decimal variables named length and width that contain the dimensions of a rectangle, write a statement that calculates the ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers