3 Replies - 258 Views - Last Post: 12 October 2012 - 07:07 PM Rate Topic: -----

#1 Sette  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-October 12

what should I do? my error is about POSSIBLE LOSS OF PRECISION :<

Posted 12 October 2012 - 10:55 AM

public void actionPerformed(ActionEvent ae) {
int  varta, ti;
int varQuiz1, varQuiz2, varQuiz3, varQuiz4, varQuiz5;
int varQuizA, varQuizB, varQuizC, varQuizD, varQuizE; 
int varQuizI, varQuizII, varQuizIII, varQuizIIII, varQuizIIIII;
double varTotal1=0, varTotal2=0, varTotal3=0, varSttl=0, varBttl=0, varNttl=0, varKKttl=0, varMttl=0, varHcttl=0, varHchttl=0, varSdattl=0, varJuittl=0, varTeattl=0, varFrttl=0, varSuttl=0, varButtl=0, varPittl=0, varRittl=0 ;
double varQuizS=0, varQuizBu=0, varQuizN=0, varQuizKK=0, varQuizM=0, varQuizHc=0, varQuizHch=0, varQuizSda=0, varQuizJui=0, varQuizTea=0,  varQuizFr=0, varQuizSun=0, varQuizBur=0, varQuizPie=0, varQuizRic=0;
double tc=0, ar=0;
if(ae.getSource()== cmdCompute) {

varTotal1 = (varSttl + varBttl + varNttl + varKKttl + varMttl);
txtTotal1.setText (String.valueOf(varTotal1));

varTotal2 = (varHcttl +  varHchttl + varSdattl + varJuittl + varTeattl);
txtTotal2.setText (String.valueOf(varTotal2));

varTotal3 = ( varFrttl + varSuttl + varButtl + varPittl + varRittl);
txtTotal3.setText (String.valueOf(varTotal3));

varta = (varTotal1 + varTotal2 + varTotal3);
txtTA.setText(" " + varta);

ti = (varQuiz1 + varQuiz2 + varQuiz3 + varQuiz4 + varQuiz5 + varQuizA + varQuizB + varQuizC + varQuizD + varQuizE + varQuizI + varQuizII + varQuizIII + varQuizIIII + varQuizIIIII);
txtTI.setText(" " +ti);

}

Posted Image

it should be the output but the Transaction of my Program is not working:<
Posted Image

Is This A Good Question/Topic? 0
  • +

Replies To: what should I do? my error is about POSSIBLE LOSS OF PRECISION :<

#2 Kinaces  Icon User is offline

  • D.I.C Head

Reputation: 78
  • View blog
  • Posts: 230
  • Joined: 04-October 12

Re: what should I do? my error is about POSSIBLE LOSS OF PRECISION :<

Posted 12 October 2012 - 11:07 AM

Quite honestly. No one is going to try to look at this code. It gave me a headache from just glancing at it. :nottalkingtoyou:

Try cleaning it up? It looks like you could use arrays to hold a lot of those variables.
Was This Post Helpful? 0
  • +
  • -

#3 rfs02  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 26
  • View blog
  • Posts: 70
  • Joined: 30-September 12

Re: what should I do? my error is about POSSIBLE LOSS OF PRECISION :<

Posted 12 October 2012 - 11:52 AM

You do need to clean up your code, and you can definitely use some arrays.

Your problem is that varta is an int, whereas varTotal1, varTotal2 and varTotal3 are doubles.

varta = (varTotal1 + varTotal2 + varTotal3);


This post has been edited by rfs02: 13 October 2012 - 04:36 AM

Was This Post Helpful? 0
  • +
  • -

#4 Sette  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 08-October 12

Re: what should I do? my error is about POSSIBLE LOSS OF PRECISION :<

Posted 12 October 2012 - 07:07 PM

View Postrfs02, on 12 October 2012 - 11:52 AM, said:

You do need to clean up your code, and you can definitely use some variables.

Your problem is that varta is an int, whereas varTotal1, varTotal2 and varTotal3 are doubles.

varta = (varTotal1 + varTotal2 + varTotal3);


thanks! a lot:))

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1