โ Back to Encapsulation
Question 462
Format a Field as a String
Format a Field as a String
Create a classBatterywhose constructor stores aprivate int level. Add a read-only propertyStatusthat returns the level followed by a percent sign, like80%. Do not write aMainmethod. Fornew Battery(80)the program prints: 80%
Expected Output:
80%
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.