Here's the javascript code I did,
Here is the output from my code
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed yesterday.
Edit questionDelete question
Here's the java code I did,
public class BillyDriverExam {
private char []exam_answer_key = {'B','D','A','A','C','A','B','A','C','D','B','C','D','A','D','C','C','B','D','A'};
private char []student_answer;
public BillyDriverExam(char []exam_answers)
{
student_answer = exam_answers;
}
public int totalCorrect()
{
int number_of_correct_answers = 0;
for (int i = 0; i < exam_answer_key.length; i++)
{
if (exam_answer_key == student_answer)
{
number_of_correct_answers++;
}
}
return number_of_correct_answers;
}
public int totalIncorrect()
{
int number_of_incorrect_answers = 0;
for (int i = 0; i < exam_answer_key.length; i++)
{
if (exam_answer_key != student_answer)
{
number_of_incorrect_answers++;
}
}
return number_of_incorrect_answers;
}
public boolean passed()
{
int passingscore = 0;
for (int i = 0; i < exam_answer_key.length; i++)
{
if (exam_answer_key == student_answer)
{
passingscore++;
}
}
if (passingscore >= 15 || passingscore >=20)
{
return true;
}
return false;
}
public int[] questionsMissed()
{
int [] missed_questions = new int [exam_answer_key.length];
int index = 0;
for (int i = 0; i < student_answer.length; i++)
{[![enter image description here](https://i.stack.imgur.com/rUKNC.png)](https://i.stack.imgur.com/rUKNC.png)
if (student_answer!= exam_answer_key)
{
missed_questions[index] = i+1;
index = index+1;
}
}
return missed_questions;
}
}
Here is my output from my code,
I was expecting the missed questions to have no zeros in the array and only numbers from the user's input.
Here is the other part of my code
Can someone help me on this?
JavaScript:
public class SamDriverExam {
private char []exam_answer_key = {'B','D','A','A','C','A','B','A','C','D','B','C','D','A','D','C','C','B','D','A'};
private char []student_answer;
public SamDriverExam(char []exam_answers)
{
student_answer = exam_answers;
}
public int totalCorrect()
{
int number_of_correct_answers = 0;
for (int i = 0; i < exam_answer_key.length; i++)
{
if (exam_answer_key[i] == student_answer[i])
{
number_of_correct_answers++;
}
}
return number_of_correct_answers;
}
public int totalIncorrect()
{
int number_of_incorrect_answers = 0;
for (int i = 0; i < exam_answer_key.length; i++)
{
if (exam_answer_key[i] != student_answer[i])
{
number_of_incorrect_answers++;
}
}
return number_of_incorrect_answers;
}
public boolean passed()
{
int passingscore = 0;
for (int i = 0; i < exam_answer_key.length; i++)
{
if (exam_answer_key[i] == student_answer[i])
{
passingscore++;
}
}
if (passingscore >= 15 || passingscore >=20)
{
return true;
}
return false;
}
public int[] questionsMissed()
{
int [] missed_questions = new int [exam_answer_key.length];
int index = 0;
for (int i = 0; i < student_answer.length; i++)
{
if (student_answer[i]!= exam_answer_key[i])
{
missed_questions[index] = i+1;
index = index+1;
}
}
return missed_questions;
}
}
Here is the output from my code
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed yesterday.
Edit questionDelete question
Here's the java code I did,
public class BillyDriverExam {
private char []exam_answer_key = {'B','D','A','A','C','A','B','A','C','D','B','C','D','A','D','C','C','B','D','A'};
private char []student_answer;
public BillyDriverExam(char []exam_answers)
{
student_answer = exam_answers;
}
public int totalCorrect()
{
int number_of_correct_answers = 0;
for (int i = 0; i < exam_answer_key.length; i++)
{
if (exam_answer_key == student_answer)
{
number_of_correct_answers++;
}
}
return number_of_correct_answers;
}
public int totalIncorrect()
{
int number_of_incorrect_answers = 0;
for (int i = 0; i < exam_answer_key.length; i++)
{
if (exam_answer_key != student_answer)
{
number_of_incorrect_answers++;
}
}
return number_of_incorrect_answers;
}
public boolean passed()
{
int passingscore = 0;
for (int i = 0; i < exam_answer_key.length; i++)
{
if (exam_answer_key == student_answer)
{
passingscore++;
}
}
if (passingscore >= 15 || passingscore >=20)
{
return true;
}
return false;
}
public int[] questionsMissed()
{
int [] missed_questions = new int [exam_answer_key.length];
int index = 0;
for (int i = 0; i < student_answer.length; i++)
{[![enter image description here](https://i.stack.imgur.com/rUKNC.png)](https://i.stack.imgur.com/rUKNC.png)
if (student_answer!= exam_answer_key)
{
missed_questions[index] = i+1;
index = index+1;
}
}
return missed_questions;
}
}
Here is my output from my code,
I was expecting the missed questions to have no zeros in the array and only numbers from the user's input.
Here is the other part of my code
JavaScript:
int[] missedQuestions = null;
SamDriverExam exam = new SamDriverExam(answers);
missedQuestions = exam.questionsMissed();
if (missedQuestions != null)
{
System.out.println("You missed the following questions:");
for (int i = 0; i < missedQuestions.length; i++)
System.out.print(missedQuestions[i] + " ");
}
Can someone help me on this?