Question: im having issues with a simple program that works correctly...
I'm having issues with a simple program that works correctly, but I have to submit it to Zybooks which runs several tests on it and gave me a 2/10. I posted a picture of what tests I passed and which failed and I pasted my program below. Any help will be much appreciated!
public class Planner
* The maximum number of students that may be enrolled in a single section.
* Use this and the number of students enrolled in the class to calculate
* then number of sections needed for the class.
private static final int MAX_SECTION_SIZE = 20;
* This stores the data for the class in the following order:
* info = class name (capitalized)
* info = class location
* info = number of students
* info = number of sections needed
private String info;
* Constructor for Planning class. The constructor takes in an input
* string, breaks it up, and then stores the pieces into the class
* variable info. It also does a minor calculation to fill in info.
* The class name must be capitalized when it is stored.
* The number of sections is equal to the ceiling of (NumStudents/MAX_CLASS_SIZE)
* @param input A String containing information about the class. The input
* will always be String of 4 elements separated by commas of the form:
public Planner(String input)
//TODO: split input (look at String.split()) and store necessary information in the info array.
String in = input.split(",");
int numStudents = Integer.parseInt(in);
if (numStudents % MAX_SECTION_SIZE == 0)
sections = numStudents / MAX_SECTION_SIZE;
sections = numStudents / (MAX_SECTION_SIZE + 1);
input = input + "," + Integer.toString(sections);
info = input.split(",");
* Getter method for the info array.
* @return information
public String getInfo()
// TODO: return info array
* This is the toString method. It overrides the default toString method
* to print out the information in the desired format.
* @return The string representation of the Planning object. The string is of the
* "CLASS: (className), LOCATION: (classLocation), ENROLLED: (numberStudents), SECTIONS: (numberSections)"
* Replace the parenthesized section with the stored values. e.g.
* if the class name is "CS2334", the first part of the string is "CLASS: CS2334"
* Make sure that all spaces and punctation are replicated exactly.
public String toString()
//TODO: construct and return correct string.
return String.format("CLASS: " + info.toUpperCase() + ", LOCATION: " + info + ", ENROLLED: " +
info + ", SECTIONS: " + info);