Results 1 to 13 of 13
  1. #1
    patricia0317 is offline Member
    Join Date
    Jul 2012
    Posts
    5
    Rep Power
    0

    Default I need help, please

    hello! im just a beginner at making source codes and i dont know if the code below is right.
    i want this to be a Dialog and for the Scanner to be an Input dialog.
    i always get so many errors. what should i do?
    i need this program for my case study in programming 2.
    Can someone please help me?
    You can just post the code as your reply. please thanks


    import java.util.Scanner;
    public class FinalGrade
    {
    public static void main(String[] arg)
    {
    String studName;
    int grade;
    double unitGrade;
    Scanner inputDevice = new Scanner(System.in);
    System.out.println("Hello! Good Day to you!");
    System.out.println("What is your name?");
    studName= inputDevice.nextLine();
    System.out.println("Enter your grade: ");
    grade= inputDevice.nextInt();
    if(grade<=100 && grade>=96)
    {
    unitGrade=1;
    System.out.println("Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=95 && grade>=94)
    {
    unitGrade=1.25;
    System.out.println("Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=93 && grade>=91)
    {
    unitGrade=1.50;
    System.out.println("Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=90 && grade>=89)
    {
    unitGrade=1.75;
    System.out.println("Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=88 && grade>=86)
    {
    unitGrade=2;
    System.out.println("Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=85 && grade>=83)
    {
    unitGrade=2.25;
    System.out.println("Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=82 && grade>=80)
    {
    unitGrade=2.50;
    System.out.println("Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=79 && grade>=77)
    {
    unitGrade=2.75;
    System.out.println("Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=76 && grade>=73)
    {
    unitGrade=3;
    System.out.println("Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=72)
    {
    unitGrade=5;
    System.out.println("Your Unit Grade is: " + unitGrade);
    }
    if(grade>=72)
    {
    System.out.println("Congratulations! " + studName + "\nYou passed!");
    }
    else
    {
    System.out.println("Sorry " + studName + " you failed." + "\nTry again next semester :(");
    }
    }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default Re: I need help, please

    See my sig re: code requests...

    Please use [code] tags [/code] when posting code so that it stays formatted.

    What errors are you getting and where are they occuring in the above code?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    patricia0317 is offline Member
    Join Date
    Jul 2012
    Posts
    5
    Rep Power
    0

    Default Re: I need help, please

    in this part ==> System.out.println("Enter your grade: ");
    everytime i made this as an ==> grade = JOptionPane.showInputDialg("Enter your grade: ");
    i always get an error says that "FinalGrade.java:11: error: cannot find symbol .... symbol: method showInputDialog(String) location: class JOptionPane" what should i do?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default Re: I need help, please

    Have you imported JOptionPane?
    (Then again, that would give a different error).
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    patricia0317 is offline Member
    Join Date
    Jul 2012
    Posts
    5
    Rep Power
    0

    Default Re: I need help, please

    what do you mean by importing JOptionPane?
    please help me i really dont know anything.
    all i want is to make this as a program that has Dialog box
    btw thanks for replying :D

  6. #6
    Ajinkya is offline Member
    Join Date
    Jul 2012
    Posts
    9
    Rep Power
    0

    Default Re: I need help, please

    Quote Originally Posted by patricia0317 View Post
    what do you mean by importing JOptionPane?
    please help me i really dont know anything.
    all i want is to make this as a program that has Dialog box
    btw thanks for replying :D
    import javax.swing.*; <- type this in the very very first line of the code i.e. line 1

  7. #7
    patricia0317 is offline Member
    Join Date
    Jul 2012
    Posts
    5
    Rep Power
    0

    Default Re: I need help, please

    yes i already get it. this is what i did

    import javax.swing.JOptionPane;
    public class FinalGrade1
    {
    public static void main(String[] arg)
    {
    String studName;
    int grade;
    double unitGrade;
    JOptionPane.showMessageDialog(null, "Hello! Good Day to you!");
    studName = JOptionPane.showInputDialog(null, "What is your name?");
    grade = Integer.parseInt(JOptionPane.showInputDialog("Ente r your grade: "));
    if(grade<=100 && grade>=96)
    {
    unitGrade=1;
    JOptionPane.showMessageDialog(null, "Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=95 && grade>=94)
    {
    unitGrade=1.25;
    JOptionPane.showMessageDialog(null, "Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=93 && grade>=91)
    {
    unitGrade=1.50;
    JOptionPane.showMessageDialog(null, "Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=90 && grade>=89)
    {
    unitGrade=1.75;
    JOptionPane.showMessageDialog(null, "Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=88 && grade>=86)
    {
    unitGrade=2;
    JOptionPane.showMessageDialog(null, "Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=85 && grade>=83)
    {
    unitGrade=2.25;
    JOptionPane.showMessageDialog(null, "Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=82 && grade>=80)
    {
    unitGrade=2.50;
    JOptionPane.showMessageDialog(null, "Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=79 && grade>=77)
    {
    unitGrade=2.75;
    JOptionPane.showMessageDialog(null, "Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=76 && grade>=73)
    {
    unitGrade=3;
    JOptionPane.showMessageDialog(null, "Your Unit Grade is: " + unitGrade);
    }
    else
    if(grade<=72)
    {
    unitGrade=5;
    JOptionPane.showMessageDialog(null, "Your Unit Grade is: " + unitGrade);
    }
    if(grade>=72)
    {
    JOptionPane.showMessageDialog(null, "Congratulations! " + studName + "\nYou passed!");
    }
    else
    {
    JOptionPane.showMessageDialog(null, "Sorry " + studName + " you failed." + "\nTry again next semester :(");
    }
    }
    }

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default Re: I need help, please

    So post #2 about code tags, because I'm not reading that without them.

    And after you've fixed that, you can then tell us what errors the above is giving you, because that code is not what gave you the previous error you mentioned.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  9. #9
    patricia0317 is offline Member
    Join Date
    Jul 2012
    Posts
    5
    Rep Power
    0

    Default Re: I need help, please

    you can compile and execute it, if you want
    there's no error now tnx
    the only thing that i dont know is to put some Error Message Dialog when a user didnt put any answer, can you help me with it?

  10. #10
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: I need help, please

    It was just a misspelling of Dialog

    Java Code:
    grade = JOptionPane.showInputDialg("Enter your grade: ");
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,183
    Rep Power
    20

    Default Re: I need help, please

    Except in the post mentioning the error it complains about:
    cannot find symbol .... symbol: method showInputDialog(String) location: class JOptionPane
    according to post #3.

    No spelling mistake there.

    I wish people wouldn't paraphrase errors.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  12. #12
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: I need help, please

    Quote Originally Posted by Tolls View Post
    I wish people wouldn't paraphrase errors.
    Sorry, I missed the second part of that post.

    It's possible that patricia0317 spelled "Dialog" correctly by mistake on that second part if she didn't use copy and paste (which it looks like she didn't).
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

  13. #13
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,452
    Rep Power
    20

    Default Re: I need help, please

    patricia0317, please gpo through the Forum Rules -- particularly the third paragraph.

    Also see:
    Guide For New Members
    BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •