001-005-008
Declaring and Using Constants
Easy
Problem Description
Declaring and Using Constants
In this problem, you will create a program that declares constants PI (3.14159) and TAX_RATE (0.1) using the final keyword, calculates a circle's area and a tax-included price, and displays the results to standard output.
Learning Objective: Understand how to declare and use constants (final) in Java
Overview
Create a program that declares values that should not change as constants and uses them in calculations.
Specifications
- Declare constant
PIwith value3.14159(final double) - Declare constant
TAX_RATEwith value0.1(final double) - Calculate and output the area of a circle with radius
5.0 - Calculate and output the price including tax for price
1000
Output Format
Circle area: 78.53975
Price with tax: 1100.0
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up