Find grades needed to raise your GPA.
Raising a cumulative GPA is a quality-points problem, not an averaging problem. Your completed credits already hold a fixed number of quality points (GPA x credits), and the target sets how many points the whole transcript must hold. The difference, divided by the credits you are about to take, is the term GPA you need. Because the completed block is large and immovable, a modest target can demand an unrealistic term — which is why the best-possible figure (every remaining credit at 4.0) matters as much as the requirement itself.
Term GPA needed
Required term GPA = (target GPA x total credits - current GPA x completed credits) / planned credits
Divide the quality-point shortfall by the maximum you can earn per credit. If you are 18 quality points short of your target, a straight-4.0 term earns 4 points per credit, so you need at least 4.5 credits of perfect work — and proportionally more at any realistic grade.
Because the completed credits outweigh the coming term. When the required figure exceeds 4.0 the target simply cannot be reached in one term, no matter how well you do; extend the plan over two or three terms and re-run it.
Only if your institution replaces the original grade rather than averaging both attempts. Under a replacement policy, subtract the old grade's quality points from the completed block before entering your current GPA.