Final answer:
The sentence uses commas correctly to separate the dependent and independent clauses.
Step-by-step explanation:
The correct sentence is:
To do well on the test, you will have to study, and you should also regularly attend class.
The subject of the sentence is "you," and it is followed by two independent clauses separated by a comma and a coordinating conjunction "and." The first clause is "To do well on the test, you will have to study," and the second clause is "you should also regularly attend class." The commas are used correctly to separate the dependent phrase and to separate the two independent clauses.
Learn more about Correct use of commas in a sentence