Ask your own question, for FREE!
Computer Science 17 Online
OpenStudy (anonymous):

please help me with java we have to design an application that will calculate gross salary where basic salary is input through keyboard DA is 65% of basic salary. HRA is 45% of basic salary and TA is $10. @experimentX

OpenStudy (experimentx):

?? DBMS or what??

OpenStudy (anonymous):

we have to design this program in java

OpenStudy (anonymous):

some stuff like float bs, da, hra, ta, gs;

OpenStudy (experimentx):

do you have an alogrithm??

OpenStudy (anonymous):

float bs, da, hra, ta, gs; bs= float.parsefloat(bs.setText("")); da= float.parsefloat(bs.getText()); da= bs* 65/100; da.setText(""+bs*65/100);

OpenStudy (experimentx):

you are taking input from a form??

OpenStudy (experimentx):

seems all right ...

OpenStudy (anonymous):

but i'm not getting why we are taking float?

OpenStudy (experimentx):

probably because you need to calculate in decimals

OpenStudy (anonymous):

but can we use double instead of float?

OpenStudy (anonymous):

both represents fractional no.

OpenStudy (experimentx):

sure ... if you want more precise.

OpenStudy (experimentx):

but ... i think that's unnecessary da= bs* 65/100; da.setText(""+bs*65/100); either do da= bs* 65/100; da.setText(""+da); or da.setText(""+bs* 65/100); is da your input field?

OpenStudy (anonymous):

no the input field is basic salary bs

OpenStudy (experimentx):

oh ... just do this da.setText(""+bs* 65/100); It's been a quite a lot since i programmed java.

OpenStudy (anonymous):

to be clear on your basics you can take a visit to thenewboston.org

OpenStudy (anonymous):

@vdidit : but i'm not getting why we are taking float? Ans: Double are generally used when one need the precision they provide. Also they take more memory and are slow in calculation. Where as Float are faster. For performance critical applications Integers are used in decimal calculation as they have least overhead in comparison to float and double . Float are faster than double for calculations. Read this article, where author compares performance of double against float in matrix multiplication for a nural network application. http://www.heatonresearch.com/content/choosing-between-java%E2%80%99s-float-and-double

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!