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

Thread: Student Grading

  1. #1
    Junior Member
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Student Grading

    So i am having trouble with this program. When i run it in the terminal, it asks for the student mark and the number of assesments but doesn't actually output anything. I have a feeling i'm not outputting something but i can't see where, I don't think it is the validate Input part as i did it exactly the same way as i did with my previous program and that worked perfectly.

    import io.*;
    public class studentGrades
    {
    public static void main( String [] args)
     {
     double studMark, numAsses, finalMark;
     String grade = "";
     
     studMark = ConsoleInput.readDouble("Enter the Student's Mark");
     numAsses = ConsoleInput.readDouble("Enter the number of Assesments completed");
     finalMark = Math.floor(studMark);
     
      if ( validInput(studMark, numAsses))
      {
       grade = calcCase ( studMark, numAsses, finalMark);
      }
      new String("The student's grade is " + grade);
      System.exit(0);
     }
    private static boolean validInput( double studMark, double numAsses)
     {
     boolean isValid;
     isValid = true;
     
      if ( studMark < 0.0 || studMark > 100.0)
      {
       isValid = false;
       System.out.println("Student mark must be between 0 and 100");
      }
      if ( numAsses < 0.0 || numAsses > 5.0)
      {
       isValid = false;
       System.out.println("Number of Assesments must be between 0 and 5");
      }
     return isValid;
     }
    private static String calcCase ( double studMark, double numAsses, double finalMark)
     {
      String finalGrade = "";
     switch ( (int)numAsses)
      {
      case 0:
             finalGrade = new String("DNA");
      break;
      case 1: case 2: case 3: case 4:
               if (studMark < 50.0)
               {
                    finalGrade = new String("DNC- " + studMark);
               }
      break;
      case 5:
              if (studMark < 50.0)
               {
                    finalGrade = new String("F- " + studMark);
               }
              else
               {
                    finalGrade = new String(finalMark + "-" + studMark);
               }
      break;
      }
      return finalGrade;
     }
    }

    Question:studentgrades.JPG

    Thanks in Advance


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,387
    My Mood
    Hungover
    Thanks
    144
    Thanked 628 Times in 538 Posts

    Default Re: Student Grading

    I recommend you give this a read through: How to Program (stuck on homework? READ THIS BEFORE POSTING)
    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
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,387
    My Mood
    Hungover
    Thanks
    144
    Thanked 628 Times in 538 Posts

    Default Re: Student Grading

    Also, you are not the first person to ask about this assignment. Some of your classmates must be on here too. Try a forum search.
    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!

  4. #4
    Junior Member
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Student Grading

    Do you happen to have a link to one?
    I've been searching for a good 20 minutes now and can only find similar programs but not one like this. I'll keep searching i suppose!

  5. #5
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,387
    My Mood
    Hungover
    Thanks
    144
    Thanked 628 Times in 538 Posts

    Default Re: Student Grading

    Quote Originally Posted by happychild View Post
    Do you happen to have a link to one?
    I've been searching for a good 20 minutes now and can only find similar programs but not one like this. I'll keep searching i suppose!
    Mostly, I'd follow the guidelines and try to work through it, asking questions in the way outlined as you go.
    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. student CGPA
    By adamu adamu in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 8th, 2011, 06:52 AM
  2. [SOLVED] Student grading application
    By Melawe in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 18th, 2011, 12:08 AM
  3. grading program help
    By devilhanzou in forum What's Wrong With My Code?
    Replies: 6
    Last Post: February 14th, 2011, 08:01 AM
  4. Grading
    By BuhRock in forum Java Theory & Questions
    Replies: 5
    Last Post: April 18th, 2010, 05:05 PM
  5. [SOLVED] Problem with Grading calculator in java program
    By Peetah05 in forum What's Wrong With My Code?
    Replies: 23
    Last Post: March 28th, 2009, 04:25 PM