Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Please solve my problem

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please solve my problem

    I want to calculate grade of students but a red line is shown in the last line below the word 'grade'.Please help.
    This is my coding:-
    int eng=Integer.parseInt(jTextField1.getText());
    int eco=Integer.parseInt(jTextField2.getText());
    int acc=Integer.parseInt(jTextField3.getText());
    int bus=Integer.parseInt(jTextField4.getText());
    int ip=Integer.parseInt(jTextField5.getText());
    int pe=Integer.parseInt(jTextField6.getText());
    int tot=eng+eco+acc+bus+ip+pe;
    float avg=tot/6;
    jTextField7.setText(""+tot);
    jTextField8.setText(""+avg);
    char grade;
    if(avg>90)
    {
    grade='A';
    }
    else
    if(avg>75&&avg<=90)
    {
    grade='B';

    }
    else
    if(avg>60&&avg<=75)
    {
    grade='C';
    }
    else
    if(avg>50&&avg<=60)
    {
    grade='D';
    }
    else
    if(avg>40&&avg<=50)
    {
    grade='E';
    }
    else
    if(avg>30&&avg<=40)
    {
    grade='F';
    }
    jTextField9.setText(""+grade);


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Please solve my problem

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags per the above link.

  3. #3
    Member Ada Lovelace's Avatar
    Join Date
    May 2014
    Location
    South England UK
    Posts
    414
    My Mood
    Angelic
    Thanks
    27
    Thanked 61 Times in 55 Posts

    Default Re: Please solve my problem

    Red line = error message? What is the error message?

    Wishes Ada xx
    If to Err is human - then programmers are most human of us all.
    "The Analytical Engine offers a new, a vast, and a powerful language . . .
    for the purposes of mankind
    ."
    Augusta Ada Byron, Lady Lovelace (1851)

Similar Threads

  1. Please solve my problem
    By Supun Pramoda in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 24th, 2014, 04:04 PM
  2. please solve the problem
    By liz in forum Threads
    Replies: 1
    Last Post: February 6th, 2014, 05:27 AM
  3. please solve my problem
    By anarica in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 12th, 2013, 07:35 AM
  4. please solve my problem
    By joy1604 in forum What's Wrong With My Code?
    Replies: 6
    Last Post: July 8th, 2013, 08:34 PM
  5. Need help to solve this problem
    By ahanf in forum Object Oriented Programming
    Replies: 1
    Last Post: June 3rd, 2012, 05:00 AM