d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > How To Fix My Code?
Add Reply New Topic New Poll
Member
Posts: 31,390
Joined: Mar 25 2009
Gold: 99.00
May 21 2020 08:09pm
https://github.com/ferfykins/FerfsMathGame/blob/master/src/com/company/FerfsMathGame.java

(EDIT: btw don't pay attention to other classes, they're not important)



Basically, not sure what to do about this code specifically:
Code
public static int numCorrect;
public static int numWrong;
public static int totalQuestions = numCorrect + numWrong;
public static float percentCorrect = (float) numCorrect / totalQuestions;





i get NaN when getting percentCorrect variable..... also i tinkered with it
and tried this:
Code
public static int numCorrect;
public static int numWrong;
public static int totalQuestions = 1+numCorrect + numWrong;
public static int percentCorrect = numCorrect / totalQuestions;
public static float percentCorrect = (float) numCorrect / totalQuestions;



but with this i always get 0%.......






^basically niether of these ways work as it should.... trying to find correct answers % percentage.... Thanks guys

This post was edited by ferf on May 21 2020 08:11pm
Member
Posts: 31,390
Joined: Mar 25 2009
Gold: 99.00
May 22 2020 02:56pm
Code is finished/working now.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll