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.

Page 1 of 2 12 LastLast
Results 1 to 25 of 26

Thread: student grade

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

    Angry student grade

    prompts user for the grades of each of the students and saves them an int array called grades. Your program shall check that the grade is between 0 and 100. program should then check if the grade is equal to or greater than 50, where 50 is the pass rate.

    A sample output :

    Enter the number of students: 3

    Enter the grade for student 1: 55

    Enter the grade for student 2: 108

    Invalid grade, try again...

    Enter the grade for student 2: 56

    Enter the grade for student 3: 57

    The average is 56.0

    The maximum is 57

    The minimum grade is 55

    The number of fails is 0

    The number of passes is 3
    ..


    im quiet stuck on this one. I be pleased if I can get as much help as I can or some examples shown to me ..

    our lecturer hasn't thought us a lot about java coding and now all of us are lost this is on of our projects we have to do.

    thanks


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    What have you tried?
    Do you have any specific questions?

    Be sure to wrap any posted code in code tags:

    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

    I haven't that much done im confused so I gave up on it. downloaded a book also started reading it.

    im just behind othersa. due to family problems at home. ive no one else to help me from my class . I don't really talk to them
    also ive concentrated more on other projects so I gave up un java . haven't slept properly in 2 months lucky to get 4 hours a day .

    I don't expect anybody to do my project for me but id like to get tips and put me on the right track.
    Thank you

    I have this at the started and other few lines as im doing along it with my research for the code that may suit me but not much working out at the minute

    String average = " The average is : ";
    String max = "The maximum grade is :";
    String minimum = "The minimum grade is : ";
    String fails = "The number of fails : ";
    String pass = "The number of passes";

    Scanner input = new Scanner(System.in);

    //allow user input;
    System.out.println("enter the number of students");
    int num = input.nextInt();

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    Start by defining a class with a main() method.
    It looks like you have part of this done: Have the main() method ask the user for the 1st input and read that input from the user.
    The code needs to be put in a class and in a method so that it will compile and execute.
    When that part is working, move to getting more input from the user.

    Be sure to wrap any posted code in code tags:

    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

    ok combining to what needs to be done to have the program done as it shown as example below


    "A sample output :
    Enter the number of students: 3
    Enter the grade for student 1: 55
    Enter the grade for student 2: 108
    Invalid grade, try again...
    Enter the grade for student 2: 56
    Enter the grade for student 3: 57
    The average is 56.0
    The maximum is 57
    The minimum grade is 55
    The number of fails is 0
    The number of passes is 3 "

    what else would I need to have, for a good start

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    Start slowly. Do one thing at a time: code it, compile it, execute it and test it with different values. When the tests are OK, move to the next item in the list.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

    have very little time. I found out yesterday that this has to be done by Friday . and I have web development project , networks project and another coding project done by Friday. my head is fried how much of stress i've gone trough since our tutor piled up all the projects. im only weak in java coding. its just making me sick ..


    I do research than I do the code. than im gone back to where I started .

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    Ok. Are you having problems now? Post the code and explain what the problem is.

    Be sure to wrap any posted code in code tags:

    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

    public static void main(String[] args) {
    // TODO code application logic here


    String average = " The average is : ";
    String max = "The maximum grade is :";
    String minimum = "The minimum grade is : ";
    String fails = "The number of fails : ";
    String pass = "The number of passes";


    Scanner input = new Scanner(System.in);

    //allow user input;
    System.out.println("enter the number of students");
    int numStudents = input.nextInt();

    int array[] = new int[numStudents];

    System.out.println("Student grade " + numStudents );

    for (int i = 0 ; i < array.length; i++ ) {
    System.out.println("Student "+numStudents[i];
    }
    array[i] = input.nextInt();


    }


    it sort of runs but I cant find to name " student 1 grade 87 "
    student 2 grade 59


    like the program should be able output all named and numbered arrays .

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    Be sure to wrap any posted code in code tags:

    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

     
    public static void main(String[] args) {
     // TODO code application logic here
     
     
     String average = " The average is : ";
     String max = "The maximum grade is :";
     String minimum = "The minimum grade is : ";
     String fails = "The number of fails : ";
     String pass = "The number of passes";
     
     
     Scanner input = new Scanner(System.in);
     
     //allow user input;
     System.out.println("enter the number of students");
     int numStudents = input.nextInt();
     
     int array[] = new int[numStudents];
     
     System.out.println("Student grade " + numStudents );
     
     for (int i = 0 ; i < array.length; i++ ) {
     System.out.println("Student "+numStudents[i];
     }
     array[i] = input.nextInt();
     
     
     }

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    What is the output for the program look like now? How does the output need to be changed?

    Which steps have you done and what step needs to be done next?
    If you don't understand my answer, don't ignore it, ask a question.

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

    Default Re: student grade

    im at the very start still im going round in circles.

    the program is student grade calculator.
    program asks user how many students is he going to put in ,
    6 for example;


    than program asks the user to put in the grade which will be an array called student student 1
    than student 2
    until the all 6 arrays are filled

    we also limit the array that it cant that the grades < = 100 so we don't pass the grade mark of 100

    if this happens the program will say invalid grade and will ask the user to re-enter a new number for student 3 .



    ..

    this is my 1st year in java . we only being thought from copy and paste and im confused.

    last year I found c++ to be a lot easier but we had different teacher that thought us top write the code on paper from our heads . not to copy

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    Let me restate:
    The program currently prompts for and reads the number of students.
    The next step you are working on is to read the grades for that number of students and save the grades in an array.
    Is that right?
    Do that part now and worry about the refinements in the next step.

    If you have coded in C++, does that mean you understand programming concepts like arrays and loops and assignment statements?
    If you don't understand my answer, don't ignore it, ask a question.

  15. #15
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

    last year we had brilliant teacher that thought us C++ i was able to write the code on piece of paper
    this year we have a monkey.. she showed us to copy code
    i have forgotten some C++

    with this program im not able to write it out i don't know i seem to be fried head is not thinking anymore.

    if i had it same that doesn't work i be able to fix it .


        public static void main(String[] args) {
            // TODO code application logic here
     
     
            String average = " The average is : ";
            String max = "The maximum grade is :";
            String minimum = "The minimum grade is : ";
            String fails = "The number of fails : ";
            String pass = "The number of passes";
            String Invalid = "Invalid Grade for students, Try again";
     
                    int maximum = 0;
    		int total = 0;
    		int sum = 0;
    		double avg =0 ;
    		int counter =0;
     
    		boolean repeat ;
     
     
            Scanner input = new Scanner(System.in);
     
            //allow user  input;
            System.out.println("enter the number of students");
            int numStudents = input.nextInt();
     
            int array[] = new int[numStudents];
     
            System.out.println("Student grade " + numStudents );
     
            for (int i = 0 ; i < array.length; i++ ) {
               array[i] = input.nextInt();
     
            }
     
        for (int i=0; i<=array.length; i++)  {
            {  
                total += array[i];  
            }         
            avg = (total / array.length);  
           System.out.print("the average is "+ avg);  
        }
    }
    }

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    I'm not sure if you have a problem now or what it is.
    If you don't understand my answer, don't ignore it, ask a question.

  17. #17
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

    the problem is I cant find the code I need to get my program working

  18. #18
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    I cant find the code
    What about trying to write it yourself?

    You don't learn much by copy and pasting code.
    If you don't understand my answer, don't ignore it, ask a question.

  19. #19
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

    could someone give me tips . what I actually need for my program.

    to have a program that works same way as below

    prompts user for the grades of each of the students and saves them an int array called grades. Your program shall check that the grade is between 0 and 100. program should then check if the grade is equal to or greater than 50, where 50 is the pass rate.

    A sample output :
    Enter the number of students: 3
    Enter the grade for student 1: 55
    Enter the grade for student 2: 108
    Invalid grade, try again...
    Enter the grade for student 2: 56
    Enter the grade for student 3: 57
    The average is 56.0
    The maximum is 57
    The minimum grade is 55
    The number of fails is 0
    The number of passes is 3



     public static void main(String[] args) {
            // TODO code application logic here
     
     
            String average = " The average is : ";
            String max = "The maximum grade is :";
            String minimum = "The minimum grade is : ";
            String fails = "The number of fails : ";
            String pass = "The number of passes";
            String Invalid = "Invalid Grade for students, Try again";
     
                    int maximum = 0;
    		int total = 0;
    		int sum = 0;
    		double avg =0 ;
    		int counter =0;
     
    		boolean repeat ;
     
     
            Scanner input = new Scanner(System.in);
     
            //allow user  input;
            System.out.println("enter the number of students");
            int numStudents = input.nextInt();
     
            int array[] = new int[numStudents];
     
            System.out.println("Student grade " + numStudents );
     
            for (int i = 0 ; i < array.length; i++ ) {
               array[i] = input.nextInt();
     
            }
     
        for (int i=0; i<=array.length; i++)  {
            {  
                total += array[i];  
            }         
            avg = (total / array.length);  
           System.out.print("the average is "+ avg);  
        }
    }
    }

    am I on the right track doing this program ??

  20. #20
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    am I on the right track
    What does the program's output look like? Post its output and add some comments saying what needs to be changed and/or added.
    If you don't understand my answer, don't ignore it, ask a question.

  21. #21
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

    this is output of the program



    Enter the number of students:
    3 " 3 is for user input"

    Enter the grade for student 1: 55 "55 user input "

    Enter the grade for student 2: 108 "108 user input"

    Invalid grade, try again... "program output"

    Enter the grade for student 2: 56 "56 user input"

    Enter the grade for student 3: 57 "57 user input"

    The average is 56.0 " program output"

    The maximum is 57 "program output"

    The minimum grade is 55 "program output"

    The number of fails is 0 "program output "

    The number of passes is 3 "Program output "

  22. #22
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    Ok, that looks like you are almost finished. What needs to be changed or added?
    If you don't understand my answer, don't ignore it, ask a question.

  23. The Following User Says Thank You to Norm For This Useful Post:

    student91 (April 8th, 2014)

  24. #23
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

    well a code above is what I have at the minute. im going back and forwards

    the examples of output I have shown is what has to look like when its done

  25. #24
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: student grade

    What steps have you done so far?
    What is the step that you are working on?
    If you don't understand my answer, don't ignore it, ask a question.

  26. #25
    Junior Member
    Join Date
    Apr 2014
    Posts
    13
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: student grade

    never mind im leaving this program alone. my head is fried ive been on this pc trying to build that that program for 11 hours. I think its time for me to chill and do more research later.


    thanks

Page 1 of 2 12 LastLast

Similar Threads

  1. class name and grade
    By ATB in forum Object Oriented Programming
    Replies: 1
    Last Post: April 7th, 2014, 04:46 AM
  2. translate grade
    By Rinor in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 12th, 2014, 01:46 PM
  3. Replies: 1
    Last Post: May 31st, 2013, 06:21 AM
  4. Java Grade Caculator
    By egingras in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 5th, 2012, 06:37 AM
  5. How to display grade using graph?
    By Wai Wai in forum Java Theory & Questions
    Replies: 1
    Last Post: August 4th, 2012, 07:06 AM