Results 1 to 3 of 3
  1. #1
    seongchog is offline Member
    Join Date
    Sep 2011
    Posts
    11
    Rep Power
    0

    Default cant solve my problem .needs some help(C++):(y):

    The Grade Point Average(GPA)is a number, calculated to 3 decimal places, which indicated the performance of a student in an examination. It is calcualted by the formula:

    GPA = Total Grade Points / Total subject taken

    Grade Grade Point
    A 4.0
    B 3.0
    C 2.0
    D 1.0
    F 0.0
    The above table shows the respective grade and its grade point.

    GPA ScholarShip
    >=3.85 100%
    >=3.75 75%
    >=3.65 50%
    The above table shows the respective GPA and percentage of Scholarships awarded.
    3.0 Task 1: Program

    (i) You are required to :
    - use Two Dimensional Array to store the grades of all students in a class as shown in the result table below:

    Subject


    S1 S2 S3 S4 S5
    1 A A A A A
    Student 2 A A A A B
    3 A B B C C
    : : : : : :
    N A B C D F

    The diagram above shows how the results are represented by using a two dimensional array with N rows (Class Size) and 5 columns(subjects).

    - have all the necessary validation in place, e.g.
    Grade ranges from A to D and F only.
    - The number of students in a class is not fixed. Use #define CLASS_SIZE …. To cater for the required size.
    - The program calculates the grade point average (GPA) for each student.
    - Examination Report will be generated with the following format:


    Examination Report
    Student No. Subject

    S1 S2 S3 S4 S5 GPA
    1 A A A A A 4.0
    2 A A A A B
    3 A B B C C
    : : : : : :
    N A B C D F

    Average GPA = ……

    Highest GPA =…… obtained by Student No……
    Lowest GPA =…… obtained by Student No……


    (ii) Create a Student File that contains the following fields:

    Field e.g.
    Student Id 01234ADIA
    Name Tan Kelvin
    Gender M
    Programme DIA
    Year of Study 1
    Semester 2
    Fees RM1365.00

    Define a structure that can store a student’s details. Create an array of this structure to store details of all students in the class. The details are to be keyed in by the user. (The first student’s details will be stored as the first element of the array, and so on).


    (iii) You are required to write a Maintenance program to allow the user :
    - to add (append) more records for new students to the file. The program should ask for the new student details, validate them, and then append them to the file.(eg. Student Id is 5 digits followed by 4 alphabets, etc).
    - to modify student’s details.
    - to delete student’s record.
    (iv) Reorganize your program functions so that users will first see a splash screen and a menu before proceeding, eg:

    GPA and Bill Processing System
    [1] Student Records Maintenance
    [2] Process Examination Report
    [3] Generate bill
    [9] Exit

    //================================================== ============
    Here is My code:(if Any wrong Pls correct for me thx):
    //================================================== ====
    #include<stdio.h>
    #include<stdlib.h>
    #define CLASS_SIZE 2

    int option;
    typedef struct
    {
    char student_id[25],name[25],gender[10],programme[10];

    int year,sememster;
    double fees,gpa;
    char arr[CLASS_SIZE][2];

    }stud;

    stud student[CLASS_SIZE];

    void main()
    {
    printf("__________________________________________ ________________________________\n\n");
    printf(" GPA and Bill Processing System\n" );
    printf("__________________________________________ ________________________________\n\n");
    printf("[1] Student Records Maintenance \n");
    printf("[2] Process Examination Report \n");
    printf("[3] Generate bill \n");
    printf("[9] Exit \n\n");
    printf("__________________________________________ ________________________________\n\n");
    printf("Please enter your choice: ");
    scanf("%d",&option);





    FILE *ofp;

    int i, j ,high,low;
    double highest,lowest=5,total=0,average,gpa=0;

    ofp=fopen("Bill.txt","a+");

    if(!ofp)
    {
    printf("ERROR--- The file cannot open !\n");
    exit(-1);
    }
    else
    {
    for(i = 0; i < CLASS_SIZE; i++)
    {
    printf("Student Detail %d\n",i+1);
    printf("------------------------\n");
    printf("Student ID : ");
    fflush(stdin);
    scanf("%s",student[i].student_id);

    printf("Name : ");
    fflush(stdin);
    scanf("%[^\n]",student[i].name);

    printf("Gender : ");
    fflush(stdin);
    scanf("%s",&student[i].gender);

    printf("Programme : ");
    fflush(stdin);
    scanf("[^\n]",&student[i].programme);

    printf("Study year : ");
    fflush(stdin);
    scanf("%d",&student[i].year);

    printf("Semester : ");
    fflush(stdin);
    scanf("%d",&student[i].sememster);

    printf("Fees : ");
    fflush(stdin);
    scanf("%lf",&student[i].fees);

    for(j = 1; j <= 5; j++)
    {
    printf("Enter Grade subject %d : ",j+1);
    fflush(stdin);
    scanf("%c",&student[i].arr[i][j]);

    if(toupper(student[i].arr[i][j])=='A')
    student[i].arr[i][j]=4;

    else if(toupper(student[i].arr[i][j])=='B')
    student[i].arr[i][j]=3;

    else if(toupper(student[i].arr[i][j])=='C')
    student[i].arr[i][j]=2;

    else if(toupper(student[i].arr[i][j])=='D')
    student[i].arr[i][j]=1;

    else if(toupper(student[i].arr[i][j])=='F')
    student[i].arr[i][j]=0;

    student[i].gpa+=student[i].arr[i][j];
    }
    student[i].gpa=student[i].gpa/5;
    printf("GPA = %.3lf\n\n",student[i].gpa);
    printf("========================================== ===============\n\n");

    }
    for(i=0 ; i < CLASS_SIZE; i++)
    {
    if(student[i].gpa > highest)
    {
    highest=student[i].gpa;
    high = i;
    }
    if(student[i].gpa < lowest)
    {
    lowest=student[i].gpa;
    low = i;
    }

    total=total+student[i].gpa;
    average=total/CLASS_SIZE;

    fprintf(ofp,"%s|%s|%s|%s|%d|%d|%lf|",student[i].student_id,student[i].name,student[i].gender,
    student[i].programme,student[i].year,student[i].sememster,student[i].fees);
    }
    printf("Average GPA : %.3lf\n",average);
    printf("Highest GPA : %.3lf (student %d))\n",highest,high+1);
    printf("Lowest GPA : %.3lf (student %d))\n",lowest,low+1);


    }
    }

  2. #2
    Iron Lion is offline Senior Member
    Join Date
    Nov 2010
    Posts
    210
    Rep Power
    4

    Default Re: cant solve my problem .needs some help(C++):(y):

    This is neither a C++ forum or a homework service. When you do find an appropriate forum I suggest you ask a more specific question rather than "here's my code, fix it".

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,453
    Blog Entries
    7
    Rep Power
    20

    Default Re: cant solve my problem .needs some help(C++):(y):

    You're right; I'm closing this thread.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Solve JVM Problem
    By pedroffbarbosa in forum Advanced Java
    Replies: 8
    Last Post: 11-28-2011, 11:35 PM
  2. Problem that I can't solve...
    By Wing.Sham in forum New To Java
    Replies: 9
    Last Post: 11-16-2011, 01:31 AM
  3. Could someone help me to solve this problem...
    By Vinny in forum Java Software
    Replies: 1
    Last Post: 07-08-2009, 06:59 PM
  4. Help me to solve problem
    By mansoorhacker in forum Forum Guides
    Replies: 8
    Last Post: 01-24-2009, 06:29 PM
  5. Solve my Problem
    By kyo in forum New To Java
    Replies: 1
    Last Post: 12-16-2008, 02:22 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
  •