Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is the assignment: http://www.eng.auburn.edu/~cross/comp1210/Lab/Projects/P

ID: 3632556 • Letter: T

Question

This is the assignment: http://www.eng.auburn.edu/~cross/comp1210/Lab/Projects/Project_09.pdf

I need help with the displayQuestion method in the QuizQuestion class. I need to split the text of the question after 50 characters but not splitting a word. This is what I have so far:

public String displayQuestion() {

Scanner s = new Scanner(question);

if (index.length() == 0) {
if (question.length() <= 50) {
output = "Question __:"
+ " " + question;
}
else if (question.length() > 50) {
while (s.hasNext()) {
output = "Question __:"                  //This only prints the last word of the question so it's wrong
+ " " + s.next();
}

}
return output;
}
else if (index.length() > 0) {
output = "Question: " + index
+ " ";
if (question.length() <= 50) {
output += question;
}
else if (question.length() > 50) {

while (s.hasNext()) {
output += question.split(" ") + " " + s.next();   //This prints every word in a new line, also wrong.
}
}
}

return output;
}
return output;
}

Explanation / Answer

import java.util.ArrayList;
import java.util.List;

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote