โ Back to Encapsulation
Question 472
Two Properties, One Field
Two Properties, One Field
Create a classTemperaturebacked by aprivate double celsius. ACelsiusproperty reads and writes that field. A read-onlyFahrenheitproperty returnscelsius * 9 / 5 + 32. Do not write aMainmethod. After settingCelsiusto 100, the program prints the Fahrenheit value: 212
Expected Output:
212
Topics:
Encapsulation
Code Editor
1
Tab to indent ยท Ctrl+Enter to run ยท Ctrl+Space to expand shortcuts (cw, cr, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.