Ask Question
3 July, 03:14

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

+4
Answers (1)
  1. 3 July, 05:25
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers