I added in the System.err.flush(); and System.out.flush(); however the problem still exists. It appears as if these printf statements are being output at a random unorthodox order.
When the (absoluteFinalGrade % 1) ranges from 0.45 to 0.49, I would like the output to be printed in red. This is because since I am given hundreds of lines of output, I would like the important ones to stand out. However, system.err.printf seems to be glitching my output in an unorthodox way. Is it possible to use a different method to make my text standout?
import java.util.Scanner;
public class FinalChemistryGradeCalculator {
public static void main (String [] args) {
Scanner input = new Scanner (System.in);
Scanner input2 = new Scanner (System.in);
double termGrade;
double examinationGrade;
double examinationMarkScore;
double examinationMarkTotal;
double lowestTestGrade;
double lowestTestMarkScore;
double lowestTestMarkTotal;
double initialFinalGrade;
double absoluteFinalGrade;
System.out.printf("Input the term grade.%n");
termGrade = input.nextDouble();
System.out.printf("%nThe term grade is %.2f.%n", termGrade);
System.out.printf("%nInput the lowest test mark score.");
lowestTestMarkScore = input.nextDouble();
System.out.printf("%nInput the lowest test mark total.");
lowestTestMarkTotal = input.nextDouble();
lowestTestGrade = (lowestTestMarkScore/lowestTestMarkTotal) * 100;
System.out.printf("%nThe lowest test grade is %.2f.%n", lowestTestGrade);
System.out.printf("%nInput the examination mark total.");
examinationMarkTotal = input.nextDouble();
for (examinationMarkScore = 0; examinationMarkScore <= examinationMarkTotal; examinationMarkScore += 0.5) {
examinationGrade = (examinationMarkScore/examinationMarkTotal) * 100;
initialFinalGrade = (termGrade * 0.7) + (examinationGrade * 0.3);
if (lowestTestGrade < examinationGrade) {
absoluteFinalGrade = initialFinalGrade - (lowestTestGrade * 0.05) + (examinationGrade * 0.05);
}
else {
absoluteFinalGrade = initialFinalGrade;
}
if (absoluteFinalGrade % 1 >= 0.45 && absoluteFinalGrade % 1 <= 0.49) {
System.err.printf("%n%n--------------------------------------------------------------------------------------------------------------");
System.err.printf("%nTerm Grade: %.2f ||||| Examination Grade: %.2f (%.1f/%.1f) ||||| Lowest Test Grade: %.2f (%.1f/%.1f)", termGrade, examinationGrade, examinationMarkScore, examinationMarkTotal, lowestTestGrade, lowestTestMarkScore, lowestTestMarkTotal);
System.err.printf("%nInitial Final Grade: %.2f ||||| Absolute Final Grade: %.2f", initialFinalGrade, absoluteFinalGrade);
System.err.printf("%n--------------------------------------------------------------------------------------------------------------");
System.err.flush();
}
else {
System.out.printf("%n%n--------------------------------------------------------------------------------------------------------------");
System.out.printf("%nTerm Grade: %.2f ||||| Examination Grade: %.2f (%.1f/%.1f) ||||| Lowest Test Grade: %.2f (%.1f/%.1f)", termGrade, examinationGrade, examinationMarkScore, examinationMarkTotal, lowestTestGrade, lowestTestMarkScore, lowestTestMarkTotal);
System.out.printf("%nInitial Final Grade: %.2f ||||| Absolute Final Grade: %.2f", initialFinalGrade, absoluteFinalGrade);
System.out.printf("%n--------------------------------------------------------------------------------------------------------------");
System.out.flush();
}
}
}
}