Ask Question

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.)

+2
Answers (1)
  1. 17 March, 15:58
    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?
Find 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 the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers