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 7 of 7

Thread: Students/Grades

  1. #1
    Junior Member
    Join Date
    Aug 2011
    Posts
    21
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Students/Grades

    import java.util.Scanner;
     
    public class Students{
    public static void main (String args []) {
    Scanner input = new Scanner(System.in);
     
    String studentName; //first input by user
    double MidTerm_Grade;//second input by user
    double Final_Grade;//sum of all grades
    double student_Id;
     
    Student myStudent = Student(studentName);
     
    System.out.println("***                                        ***");
    System.out.println("*** Welcome to the University Grade Center ***");
    System.out.println("***                                        ***");
     
     
     
    int studentId;
    public Student(String n)
     
     
    studentName = n;
    studentId = (int)Math.random() * 10000000;
     
     
    System.out.println("\nWhat is your name? ");
    studentName = input.nextLine();
     
    System.out.println(" Enter mid term grade: ");
    midterm = input.nextLine();
     
    System.out.println(" Enter final grade: ");
    final_grade = input.nextLine();
     
     
    System.out.println("***  Student Summary     ***");
    System.out.printf("\nStudent Name: %s" studentName);
    int number = (int)(Math.random() * 10000000); // random id number for each student
    System.out.printf("\nStudent Id: %s" studentId);
    System.out.printf("\nStudent Mid Term Grade: %s" studentMidTermGrade);
    System.out.printf("\nStudent Final Grade: %s" studentFinalGrade);
     
    String my Input;
    boolean isRepeat = true;
    boolean isInitialize = false;
     
    while(isRepeat){
    if(!isInitialize){
    isInitialize = true;
    }
    else{
    System.out.println("\n\n Would you like to enter another student?"); // prompt
    myInput = input.next();
    if(myInput.equalsIgnoreCase("Yes"))
    {
    student();
    } //end if
    else if (myInput.equalsLgnoreCase("No"))// input is no so output appropriate message
    {
     
    System.out.print("The grade is " + getGrade(78.5));
    System.out.print("\nThe grade is " + getGrade(59.5));}
     
    public static char getGrade(double score){
    if (score >= 90.0)
    return 'A';
    else if (score >= 80.0)
    return 'B';
    else if (score >= 70.00)
    return 'C';
    else if (score >= 60.0)
    return 'D';
    else
    return 'F';
    }
     
        }
    }
     
    import java.util.Scanner;
    public class Grades
    {
    public static void main(String args []){
    Scanner input = new Scanner(System.in);
        private String student_name = "   ";
        private String student_id = "     ";
        private String midterm_grade = "    ";
        private String final_grade = "    ";
     
        Students n = new Students();
        private String studentName;
        int studentId;
        public Student(String n);
        {
            studentName = n;
            studentId = (int)Math.Random() * 10000000;
     
     
    public String getStudentName()
    {
    return student_name;
    }
    public void setMidTermGrade(double g)
    {
    midterm_grade = g;
    }
    public String getMidTermGrade()
    {
    return midterm_grade;
    }
    public void setFinalGrade(double g)
    {
    final_grade = g;
    {
    public String getFinalGrade()
    {
    return final_grade;
    }
    public static char getGrade(double score){
    if (score >= 90.0)
    return 'A';
    else if (score >= 80.0)
    return 'B';
    else if (score >= 70.00)
    return 'C';
    else if (score >= 60.0)
    return 'D';
    else
    return 'F';
    }
    }
     
     
        }
    }
    Im really new at this. The problems question is to write two files Students/Grades. Define the Student and Grades class and use concurrently with the Student class. I may have overuse or underused some things. HELP!!!!!!
    Last edited by KevinWorkman; September 12th, 2011 at 10:42 AM. Reason: added highlight tags

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,541
    My Mood
    Hungover
    Thanks
    145
    Thanked 648 Times in 553 Posts

    Default Re: Students/Grades

    I highly recommend you read this: How to Program (stuck on homework? READ THIS BEFORE POSTING)

    As well as the link in my signature on asking questions the smart way.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Aug 2011
    Posts
    21
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Students/Grades

    Thanks for the information, as one could see I'm new at posting as well.

  4. #4
    Junior Member
    Join Date
    Aug 2011
    Posts
    21
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Students/Grades

    The very first part that I became stuck on was in the beginning: public Student(String n) gave me an illegal start of expression error.

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,541
    My Mood
    Hungover
    Thanks
    145
    Thanked 648 Times in 553 Posts

    Default Re: Students/Grades

    Well, you've got a lot of problems, and it looks like you tried to copy and paste an old assignment into this one to get it to work (which is a "don't" in the guidelines I posted).

    There are so many syntax errors here, I honestly don't even know where to start. You might want to start over and follow the guidelines, making sure to correct syntax errors you go- it's easy to straighten out one piece of wire, but as soon as you have a drawer full of tangled up wires, it's impossible to isolate any single problem.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  6. #6
    Junior Member
    Join Date
    Aug 2011
    Posts
    21
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Students/Grades

    Maybe I'll just start over............

  7. #7
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,541
    My Mood
    Hungover
    Thanks
    145
    Thanked 648 Times in 553 Posts

    Default Re: Students/Grades

    Quote Originally Posted by ruffu054 View Post
    Maybe I'll just start over............
    That's not a bad idea, especially if this is a result of trying to mash old assignments together. Follow the guidelines, and you'll be done by lunch (depending on what time zone you're in).
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Grades project/arrays, loops
    By rochla16 in forum Collections and Generics
    Replies: 1
    Last Post: March 29th, 2011, 01:26 AM
  2. Two-Dimensional Array to Grade Students?
    By Java Neil in forum What's Wrong With My Code?
    Replies: 37
    Last Post: March 22nd, 2011, 04:47 PM
  3. Replies: 1
    Last Post: March 11th, 2011, 02:11 PM