Results 1 to 8 of 8
  1. #1
    Braxtonmj is offline Member
    Join Date
    May 2010
    Location
    nj
    Posts
    3
    Rep Power
    0

    Default Help with calculation for final grade of student

    i need help writing this program. i'm new and i need someone to check out these instructions and figure out how to write it. here is what i have , but it is not write can u help me?


    The calculation for the final grade of a student is: homework score plus project score plus test score plus exam score. If the final grade is 70 or over the student is rated as PASS. If the final grade is less than 70 the student is rated as FAIL

    Design a computer program to calculate the final grade of one or more students using the formula above. Determine if the student passed or failed. Display the studentís name, final grade, and PASS/FAIL rating..

    Design the program so that it loops for any number of students, that is the program sequence needs to repeat for each set of data.

    Some sample data are as follows:

    Name homework project test exam

    Mary 27 15 25 25

    Pete 22 14 23 24

    Bimbo 10 6 15 10





    ** this is what I written so far....









    /* Project 2 student final grade */

    import java.io.*;

    import java.lang.*;

    import java.text.*;

    import java.util.*;

    //Set up public class

    public class Grade

    {

    //declare main() method

    public static void main(String[] args) throws IOException

    {

    //Declare data types

    float name,homework,project,test,exam,FinalGrade;

    int finalgrade = 70;

    if (finalgrade ==70)

    {

    System.out.println("\n pass");

    }else{

    System.out.println("\n fail");

    }


    //set up input stream

    Scanner readin = new Scanner(System.in);

    System.out.println("\n Enter 1 for student name , 2 for no more data");

    choice = readin.nextInt();

    while (choice <2)

    {
    if (choice ==1)
    {

    // student name here

    //prompt for homework

    System.out.println("\n\n enter score of homework");

    //stream in homework and convert to float

    homework = readin.nextFloat();

    //prompt for project

    System.out.println("\n\n enter score of project");

    //stream in project and convert to float

    project = readin.nextFloat();

    // prompt for test

    System.out.println("\n\n enter score of test");

    // stream in test and convert to float

    test = readin.nextFloat();

    // prompt for exam

    System.out.println("\n\n enter score of exam");

    exam = readin.nextFloat();


    //Calculate results

    Final Grade = (homework+project+test+exam);

    //prepare data for out put display

    System.out.print("\n\nThe results of the calcuations are\n\n\n");

    System.out.println("the Final Grade is:\t\t" + (FinalGrade));


    }// end 1st if

    if (choice == 2)

    {// end 2nd if


    System.out.println("\n Enter 1 for student name , 2 for no more data");

    // input choice

    }

    choice = readin.nextInt();


    }// end while loop

    }// end main

    }// end class

  2. #2
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    Ok, first of all, code tags and proper indentation makes people more likely to help you. Next, float name? Unless people are named 3,14 and 0,5431 I don't see how that would work. A good OOP approach would be to create a class called Student, with a String name (!), and int values for grades (unless they can have fractions of a grade, in that case floats are ok), with a method called calcFinalGrade() that returns the grade, and a boolean pass() method which returns true if the final grade is over 70.
    Ever seen a dog chase its tail? Now that's an infinite loop.

  3. #3
    Braxtonmj is offline Member
    Join Date
    May 2010
    Location
    nj
    Posts
    3
    Rep Power
    0

    Default

    can u right the code for me then explain it to me? im a noob

  4. #4
    m00nchile is offline Senior Member
    Join Date
    Feb 2010
    Location
    Ljubljana, Slovenia
    Posts
    470
    Rep Power
    5

    Default

    I don't mean to come across as harsh, but this problem is made for "noobs" to get a grasp on the basics. It just requires the addition of a few values ,a check and a loop. Try to do it yourself, and generally speaking, begging for homework is frowned upon.
    Ever seen a dog chase its tail? Now that's an infinite loop.

  5. #5
    Sno's Avatar
    Sno
    Sno is offline Senior Member
    Join Date
    Apr 2010
    Posts
    196
    Rep Power
    5

    Default

    !! your code is a mess !! its all out of order! why do you have an if statement at the top? why are you using floats!?

    I suggest buying a book.
    :rolleyes: ~ Sno ~ :rolleyes:
    '-~ B.S. Computer Science ~-'

  6. #6
    Braxtonmj is offline Member
    Join Date
    May 2010
    Location
    nj
    Posts
    3
    Rep Power
    0

    Default

    lol, ill fix it and show u guys. It could take a while because of my job.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Braxtonmj View Post
    can u right the code for me then explain it to me? im a noob
    Cute.

    In a word -- no. No one is going to write this code for you and no one should.

  8. #8
    robertbob is offline Member
    Join Date
    May 2010
    Posts
    23
    Rep Power
    0

    Default

    Generally it's not the best idea to post your homework assignments on here and ask people to code them for you ;)

Similar Threads

  1. Array highest grade
    By Cdlove in forum New To Java
    Replies: 5
    Last Post: 05-05-2010, 09:25 PM
  2. Grade my questions, lol
    By syntrax in forum New To Java
    Replies: 4
    Last Post: 12-16-2009, 06:03 AM
  3. Help with JAVA (Grade Book)
    By Sara_21 in forum New To Java
    Replies: 3
    Last Post: 11-30-2009, 02:45 PM
  4. beginner grade 11-need help with RaceCar Game
    By bobmasta5 in forum New To Java
    Replies: 0
    Last Post: 01-09-2009, 09:04 PM
  5. [SOLVED] is final class members are also final ?
    By haoberoi in forum New To Java
    Replies: 4
    Last Post: 11-10-2008, 03:01 PM

Posting Permissions

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