Can U Write code to solve this problem plss help me

Discussion in 'C' started by sujan.dasmahapatra, Jun 11, 2009.

  1. sujan.dasmahapatra

    sujan.dasmahapatra Member

    Joined:
    Jun 11, 2009
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    Gender:
    Male
    Write an ANSI C program that calculates the letter grade of students in a class. The input is a file consists of student’s records, every record in a line and terminated by a newline character.
    Each line consists of
    • Student ID, a string of 8 digits
    • Student name in the form “lastname, firstname:” where the last name and the first name are separated by a comma and a single space (no middle initials).
    • Final exam mark: an integer out of 100
    • Midterm mark: an integer out of 50
    • The mark for three quizzes (each out of 10): each is an integer
    The course mark is 50% final, 30% midterm and 20% quizzes
    For the quizzes, if a student missed a quiz with a legitimate excuse, he gets “-“ (the minus sign) and the weight of this quiz is divided among the 2 other quizzes, a maximum of 1 missed quiz.
    The separation between the colon after the first name and the scores, as well as between the scores is one or more spaces.
    The maximum length of any line is 100 characters
    Your program should read and process each line until it encounters the end of the file.
    Score
    Letter grade
    >=90
    A
    >= 80 && <90
    B
    >=70 && <80
    C
    <=60 && <70
    D
    <60
    F
    The output of the program should be



    Student ID, name, and a letter grade according to the previous table, there is exactly one space between the ID and the name, and 2 spaces between the colon after the name and the letter grade. Also, each student should be on a separate line.
    After that, a single line stating “N students processed” where N is the number of students.
    Your program should be able to deal with the following cases:
    • If the student ID is not 8 digits, the letter grade is calculated and displayed, however the ID is replaced by “XXXXXXXX”
    • If any of the test or quizzes scores are missing, the ID, and name are displayed, following by “MISSING GRADE” instead of the letter grade.
    • If any mark is greater than the maximum, or a negative number display
    “ILLEGAL MARK”
    • If the length of the record is more than 100, the ID is displayed followed by
    “ILLEGAL RECORD”
    Example of an input file
    12345678 Doe John, 89 44 2 – 9
    Look at the assignment policy for details about submitting and marking
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Sounds straightforward enough. What have you got so far and where are you stuck?

    Yes, I could write the code to do it, but you would learn nothing that way.
     
  3. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Joined:
    May 5, 2009
    Messages:
    1,342
    Likes Received:
    55
    Trophy Points:
    0
    Occupation:
    STUDENT !
    Location:
    Orissa, INDIA
    Home Page:
    http://www.crackingforfun.blogspot.com
    Go4Expert is not a place for dumping your assignments and asking for their solution.
     
  4. sujan.dasmahapatra

    sujan.dasmahapatra Member

    Joined:
    Jun 11, 2009
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    Gender:
    Male
    Actually i dont understand how would I calculate the Grade......what i have undestood is that
    0.5*89+0.3*44+?????
    50% for 89 and 30% for midterm what for the 3 quizzes plss tell me how would i calculate the grade. refer the example data.
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    OK well you have to add three parts together so let's start by taking the midterm mark.
    This is marked out of 50 and accounts for up to 30% of the final score.
    So if you score 50/50 in the midterm then that would give you the full 30%.
    If you got 25/50 then that would give you half the 30% allocation which is 15%.

    What would you have to score out of 50 to get a third of the 30% allocation, i.e. 10%?
    Try with a few other numbers and that should give you some idea of how to work it out as a formula.

    The quizzes work the same way. There are three quizzes, each out of 10. If you get 10/10 for all three, that gets you the full 20%. What would you get if you scored 5/10 for all three? As with the midterm, play with some numbers and see if you can derive a formula. Don't just guess at a formula; work it out.

    Here's some example data for you. Let's say you get 50/100 for the final, 25/50 for the midterm and 5/10 for all three quizzes. What would the overall grade be?
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice