Consider this excerpt of code that converts a temperature from Fahrenheit to Celsius:

double fTemp = 75.2;

double cTemp;

cTemp = (5 / 9) * (fTemp - 32);



1. What is the problem with this code that will cause cTemp to be incorrect?

2. How can you fix the issue using type-casting?

Respuesta :

When a code segment has an error, the code would either not run at all, or it would not run properly.

  • The error in the code is the result of (5/9) will be 0
  • The fix to the error by typecasting is by writing 5 as double (5)

On the third line, we have (5/9) * (fTemp - 32).

5 and 9 are integers, and they would be executed as integers.

This means that 5/9 will result to 0.

The fix to this error by typecasting is by converting one or both of 5 and 9 to double.

This can be done by rewriting them as: double(5) and double(9)

Read more about programming errors at:

https://brainly.com/question/23782010

ACCESS MORE
EDU ACCESS