answersLogoWhite

0


Best Answer

symbolic constants are named constants

like :

final double PI = 3.14 ;

They are constants because of the 'final' keywords, so they canNOT be reassigned a new value after being declared as final

And they are symbolic , because they have a name

A NON symbolic constant is like the value of '2' in expression

int foo = 2 * 3

Answer given By Sushil Mittal..........

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

Suppose that you write a large program that uses the sales tax percentage in many places. Then, after you've been happily using your program for a few months, the state suddenly decides to raise the sales tax to seven percent. In order to get your program working again, you have to go through every line of code, looking for the .06 values that represent the sales tax and changing them to .07. Such a modification can be a great deal of work in a large program. Worse, you may miss one or two places in the code that need to be changed, leaving your program with some serious bugs.

To avoid these situations, programmers often use something called symbolic constants, which are simply words that represent values in a program. In the case of your sales tax program, you could choose a word like SALESTAX (no spaces) to represent the current sales tax percentage for your state. Then, at the beginning of your program, you set SALESTAX to be equal to the current state sales tax. In the Java language, such a line of program code might look like this:

final float SALESTAX = 0.06;

In the preceding line, the word final tells Java that this data object is going to be a constant. The float is the data type, which, in this case, is a floating point. The word SALESTAX is the symbolic constant. The equals sign tells Java that the word on the left should be equal to the value on the right, which, in this case, is 0.06.

After defining the symbolic constant SALESTAX, you can rewrite any lines that use the current sales tax value to use the symbolic constant rather than the hard-coded value. For example, the calculation for the sales tax on that $12.00 purchase might now look something like this:

tax = 12 * SALESTAX;

Now, when your state changes the sales tax to 7 percent, you need only change the value you assign to the symbolic constant and the rest of the program automatically fixes itself. The change would look like this:

final float SALESTAX = 0.07;

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What are symbolic constants and how they are useful in developing programs?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How biogas can be specially useful in developing countries?

explain how biogas can be specially useful in developing countries


Why is stdioh file used in c program?

The stdio.h file is used in c programs in order to import declarations of important functions and constants that are useful in doing input/output, using the library facilities of the compiler.


When developing a character it is useful to ask?

I, II, and III


Should programmers create programs that are useful to themselves and other people?

Why would they create programs if it won't even be useful for themselves...Ofcourse they should create programs that are useful to themselves and other people..that's why programming is invented for advantages....


What are some useful anti spyware programs?

Some useful anti spyware programs include Malwarebytes and CCleaner. Both programs can be downloaded for free from various websites like FileHippo and CNET.


Are responsible for providing and useful information for accountability of government programs and their operations?

are responsible for providing reliable and useful information for accountability of government programs and their operations.


How bio gas can be useful in developing countries?

Bio gas can be useful in developing countries because it is much cheaper and easier to get a hold of than fossil fuels which are being depleted which drives up the cost.


How is Microsoft use cein a workplace?

Microsoft has a variety of programs which are useful in the workplace. They include Word and Works which are both word processing programs. They also have a spreadsheet which can be useful.


Who responsible for providing reliable and useful information for accountability of government programs and their operations?

are responsible for providing reliable and useful information for accountability of government programs and their operations.


How mantra resort is useful for cultural programs?

they provide the best facility for cultural programs like they provide the lotus separate hall this kind of programs


Is dot net useful to web developer?

Only if you are going to be developing for the ASP.Net platform.


Is the concept of the developing world a useful one why or why not?

what you hope to gain the course development economic