Write a Java program to calculate the grade of the student using the below criteria. Grade "Excellent": Marks>75 Grade "Satisfactory": 75>Marks>50 Grade "Needs Improvement": 50>Marks>40 Grade "Failing": Marks<40
this can be done using an if statement. Here is the proper syntax: if(Marks > 75) { System.out.println("Grade \"Excellent\"."); //basically- if variable Marks is greater than //--75, it will execute everything inside the bracuts- in this case //it will execute the System class- which will inform the user //that his grade was excellent. //you can make the rest of the program with if statements like the //one I just demonstrated. //if you're wondering what the backslashes are doing in that string //literal (string literal = what is in the parenthesis after the system class) //the backslashes allow the " quotes to print, without the quotes //opening and closing the string itself. } All of the info after // is just comments that will be ignored by the compiler. Also, when I saw your question- there is one quick issue I saw in the logic; it says excellent > 75, and it says 75 > satisfactory > 50 -- if your variable 'marks' was to equal 75, it would not fall under any catagory. To fix this, use the greater than or equals to sign: >= . there is also the less than or equals to sign: <= Notice the equals sign is after the greater/less than sign. It must be in that orientation to be proper syntax. Allright- if you have any questions lemme know.
all of the words after the System.out.println(""); are comments- and should not be in your program- but remember the opening & closing brackuts.
Join our real-time social learning platform and learn together with your friends!