Hey, I'm having a bit of trouble with math operators which should work but don't.
class Assignment10 { //constructor with 8 parameters to initialize the variables Assignment10(int markQuiz1, int markQuiz2, int markQuiz3, int markQuiz4, int markQuiz5, int markMidterm, int markFinExam, String studentName) { //Calculates the grade percentages and then finds out the final grade for the class. double markQuizesFinal = (((markQuiz1 + markQuiz2 + markQuiz3 + markQuiz4 + markQuiz5) / 50) * 100); double markFinal_D = 5.7; //Temp testing value, don't pay any attention to this double decimalPlace = (markFinal_D % 1); if (decimalPlace >= 0.51) // Determines if the final mark should be rounded up or down and then rounds it up or down to get a more precise mark. { markFinal_D = (markFinal_D - decimalPlace); markFinal_D = (markFinal_D + 1); } else markFinal_D = (markFinal_D - decimalPlace); int markFinal_I = 0; //Initilizes markFinal_I and sets it to 0 so the program will compile properly. markFinal_I = (int)markFinal_D; //Casts the double markFinal_D to the interger variable markFinal_I //Prints the final grade in both numerical and letter format. System.out.print(""+studentName+"'s final Grade is:"); System.out.print(" "+markFinal_I+" "); System.out.print(" "+markQuizesFinal+" "); if (markFinal_I >= 90.0) //Determines and sets the letter grade for the student depending on their mark. System.out.print("A"); else if (markFinal_I >= 80.0 && markFinal_I < 90.0) System.out.print("B"); else if (markFinal_I >= 70.0 && markFinal_I < 80.0) System.out.print("C"); else if (markFinal_I >= 60.0 && markFinal_I < 70.0) System.out.print("D"); else if (markFinal_I < 60.0) System.out.print("F"); System.out.println(""); } } // Test Class class Assignment10Tester { public static void main (String[] args) { Assignment10 bob = new Assignment10(3, 4, 6, 2, 7, 70, 54, "bob"); Assignment10 celestia = new Assignment10(9, 8, 7, 6, 5, 97, 85, "celestia"); } }
The line that has the 'broken?' math operators in line number 9. I've done the same operation in a calculator and it does work but for some reason it's not working here.