โ Back to Encapsulation
Question 471
Computed Property With Logic
Computed Property With Logic
Create a classOrderwhose constructor stores aprivate double total. Add a read-only propertyFinalPrice: whentotalis greater than 100 it returns the total minus one tenth of the total (a 10% discount); otherwise it returns the total unchanged. Do not write aMainmethod. For a total of 200 the program prints: 180 For a total of 50 the program prints: 50
Expected Output:
180
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.