So i am having trouble with this program. When i run it in the terminal, it asks for the student mark and the number of assesments but doesn't actually output anything. I have a feeling i'm not outputting something but i can't see where, I don't think it is the validate Input part as i did it exactly the same way as i did with my previous program and that worked perfectly.
import io.*; public class studentGrades { public static void main( String [] args) { double studMark, numAsses, finalMark; String grade = ""; studMark = ConsoleInput.readDouble("Enter the Student's Mark"); numAsses = ConsoleInput.readDouble("Enter the number of Assesments completed"); finalMark = Math.floor(studMark); if ( validInput(studMark, numAsses)) { grade = calcCase ( studMark, numAsses, finalMark); } new String("The student's grade is " + grade); System.exit(0); } private static boolean validInput( double studMark, double numAsses) { boolean isValid; isValid = true; if ( studMark < 0.0 || studMark > 100.0) { isValid = false; System.out.println("Student mark must be between 0 and 100"); } if ( numAsses < 0.0 || numAsses > 5.0) { isValid = false; System.out.println("Number of Assesments must be between 0 and 5"); } return isValid; } private static String calcCase ( double studMark, double numAsses, double finalMark) { String finalGrade = ""; switch ( (int)numAsses) { case 0: finalGrade = new String("DNA"); break; case 1: case 2: case 3: case 4: if (studMark < 50.0) { finalGrade = new String("DNC- " + studMark); } break; case 5: if (studMark < 50.0) { finalGrade = new String("F- " + studMark); } else { finalGrade = new String(finalMark + "-" + studMark); } break; } return finalGrade; } }
Question:studentgrades.JPG
Thanks in Advance