001-005-008

Declaring and Using Constants

Easy

Problem Description

Declaring and Using Constants

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

  1. Declare constant PI with value 3.14159 (final double)
  2. Declare constant TAX_RATE with value 0.1 (final double)
  3. Calculate and output the area of a circle with radius 5.0
  4. 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?