0

I'm trying to create a program that read the input of name and mark of students then give out the name and grade of that student in the form GUI output but keep having the problem when compiling.

import javax.swing.*;
public class p
{ 

private static String getGrade(int mark)
{
    String grade;
    if (mark<50)
                grade="F";
              else if (mark<65)
                grade="P";
              else if (mark<75)
                grade="C";
              else if (mark<85)
                grade="D";
              else
                grade="HD";
     return grade;
}
public static void main (String []args)
{
    JOptionPane.showMessageDialog(null,"Welcome to the Mark Entry System");
    String studentName = JOptionPane.showInputDialog(null,"Enter student name:");    
    int mark =Integer.parseInt(JOptionPane.showInputDialog(null,"Enter mark for student (out of 100)"));
    String grade = getGrade(int mark);
    JOptionPane.showMessageDialog(null,"The grade for " + studentName + " is " + grade);

}
}
5
  • 1
    suppose String grade = getGrade(mark); in the main class. please share the exception or stacktrace. Commented Apr 16, 2017 at 6:34
  • Not sure I understand your questions because I just start programming for a while. I just use Bluej for programming as well as compiling Commented Apr 16, 2017 at 6:37
  • @AnhMinhTran what's the error ? Commented Apr 16, 2017 at 6:37
  • @Shashwat just that " '.class' expected" Commented Apr 16, 2017 at 6:39
  • @AnhMinhTran No. There is no such compilation error as '.class expected`. What does it really say? Commented Apr 30, 2017 at 8:39

1 Answer 1

1

Here

String grade = getGrade(int mark); //Can't do this

Pass some int like

String grade = getGrade(mark); //pass any integer you want
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you so much for helping me out. Can you explain to me what's the logic behind this changes.
String grade = getGrade(mark); according to your code shared.(+1)
Thank you so muchhhhhhhhhh, I would upvote for you twice if I could

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.