java - If statement containing char not executing -


I am trying to create a program that checks the "right" answer in every ten places in an array. I think if the condition is not executed even if the condition of the loop is satisfied with the textarray [i * 10 + k] == latter [k] (I have verified it) .

And if the statement textarray [i * 10 + k] == '' is working, then I do not know why the former does not. Any help will be very much appreciated!

  char [] textarray = new char [textfile.length ()]; For (Int i = 0; I & lt; textfile.length (); i + +) {Texturer [i] = TextFile.chirt (i); } Double [] each question = new double [10]; Double [] Each question = new double [10]; Double [] each question = new double [10]; Double [] each question = new double [10]; Double [] each launch = new double [10]; // store how many questions each student correct, wrong or left empty int [] studentcorrect = new int [textfile.length () / 10]; Int [] StudentDiscount = New Ent [textfile.length () / 10]; Int [] studentblank = new int [textfile.length () / 10]; For (int i = 0; i & lt; textfile.length () / 10, i ++) {for (integer k = 0; k & lt; 10; k ++) {if (textarray [i 10 + K *] == 'A') {Each question [i] ++; } If (Pathfire [i * 10 + k] == 'B') {Every Q & A [i] ++; } If (Lessons [i * 10 + k] == 'C') {Each Q. [i] ++; } If (Lessons [i * 10 + k] == 'D') {Each question [i] ++; } If (Lessons [i * 10 + k] == 'E') {Each question [i] ++; } If (Pathfire [i * 10 + k] == Answer to [Answer]] [Student correction [i] ++; } And if (lesser [i * 10 + k] == '') {studentblank [i] ++; } Else {studentincorrect [i] ++; }}}}  

OK, this is a bit of a mess, so I Take the first pass in your SO Code Reveal:

First of all you have to fix the issue of Ed and Bilde. We also need to know what is "textfile"? Without the data type, I'm not sure if you are evaluating either "charAt", or "length", you're not expecting.

Also, not sure that this is causing your problem, but your index has screwed up. You must use

everyquestiona [k] ++

not

eachquestiona [i] ++ < / P>

If I change the "if" statement between "a if if" statement "else if" statement (this should not be more than one) between i and "answer", then After moving the blank check, then check your "Answer" before the last "last" (without any "if" before). It can not be 'A' and 'B' and 'both', and your code should reflect that it is either right or wrong (can be the 'correct answer' in principle).

Edit:

Really a lot of changes which I will make in this code to make it clean (which will probably make the errors jump out of you less), here's about it I have a fresh start in:

  string textfile = // Start here and let us know how you completed the final integer NUMQUESTIONS = 10; // This can later be a variable which, in the end, the last number is NUMSTUDENTS = textFile.length () / NUMQUESTIONS; // Probably should check that it is double right [] each question = new double [NUMQUESTIONS]; Double [] Each question = new double [NUMQUESTIONS]; Double [] each question = new double [NUMQUESTIONS]; Double [] each question = new double [NUMQUESTIONS]; Double [] each question = new double [NUMQUESTIONS]; // store how many questions each student correct, wrong or left empty int [] studentcorrect = new int [NUMSTUDENTS]; Int [] studentIncorrect = new int [NUMSTUDENTS]; Int [] studentblank = new int [NUMSTUDENTS]; (; StudentCount & LT; NUMSTUDENTS; studentCount ++ integer studentCount = 0) to {(int answerCount = 0; answerCount & LT; NUMQUESTIONS; answerCount ++) for {char thisAnswer = Character.toUpperCase (charAt (studentCount * NUMQUESTIONS + AnswerCount)); Switch (this answer) {case "A": every question [answercard] ++; break; Case 'B': Each question [answer count] ++; break; Case 'C': Each question [answer count] ++; break; Case 'D': each question [Uttrkount] ++; break; Case 'E': Each question [answer count] ++; break; Case '': Student Blank [studentCount] ++; break; } If (This answer == character. Answer: Answer (Answer [answercount])) {Student correction [studentCount] ++; } And {studentend [studentCount] ++; }}}  

Type me if there is a typo - I have not actually run it.


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -