Function problem...

Discussion in 'C' started by khelly, Dec 1, 2011.

  1. khelly

    khelly New Member

    Joined:
    Dec 1, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    UNI Quality Assurance department has decided to do Teaching & Learning Evaluation for every lecturer in UPSI. In this evaluation, each student will have to key in the grade for the lecturer whether A, B, C or D and the marks for each grade are shown in table 1.

    Grade | Mark
    A | 4
    B | 3
    C | 2
    D | 1

    Table 1


    Using a modular programming approached (function by reference), write a program to calculate the average mark that a lecturer had obtained and then display the result. The program also should display the lecturer’s status based on the total marks whereby status for each range of marks is shown in table 2.

    Mark | Status
    3.5<=average<=100 | Excellence
    3.0<=average<3.5 | Good
    2.0<=average<3.0 | Average
    average<2.0 | Poor

    Table 2

    Your program should at least have the following functions:-
    i. Function Average_Calculation – to calculate average mark
    ii. Function Status – to determine the status.
    iii. Function Display – display the result


    Notes: Assumed the lecturer has M number of students.

    Example of output :

    UNI
    Teaching & Learning Evaluation Report​

    Name : Natasya
    Subject Code : MTS 3013
    Average Mark : 3.8
    Status : Excellence


    [sup]
    PLZ, I NEED TO SUBMIT 5 DAYS LEFT, MAY GOD BLESS U IF U HELP ME...[/sup]
     
  2. xpi0t0s

    xpi0t0s Mentor

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

    Note that this is not a free homework doing site. We'll help you, but not by doing your work for you.
     
  3. khelly

    khelly New Member

    Joined:
    Dec 1, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    i will post mine soon, i will, i'm sure...

    asap i will bcoz just in time i need to submit...
     
  4. khelly

    khelly New Member

    Joined:
    Dec 1, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    So, there is my coding, but i use, loop, and if else, BUT the one suppose is Function...

    Code:
    #include<iostream.h>
    #include<string.h>
    int main()
    {
    	char lect_name[30],subject[30];
    	char grade,status;
    	int mark;
    	int numbof_student;
    	float sum=0;
    	float average;
    	
    	cout<<"Enter Your Lecturer name : ";
    	cin>>lect_name;
    	
    	cout<<"Enter Your Subject code : ";
    	cin>>subject;
    	
    	cout<<"Enter Number Of Student : ";
    	cin>>numbof_student;
    	
    	for(int s=0; s<numbof_student; s++)
    	{
    		cout<<s+1<<" student enter grade:";
    		cin>>grade;
    		
    		if(grade=='A')
    		{
    		mark=4;
    		}
    		
    		else if(grade=='B')
    		{
    		mark=3;
    		}
    		
    		else if(grade=='C')
    		{
    		mark=2;
    		}
    		
    		else if(grade=='D')
    		{
    		mark=1;
    		}
    		
    		else 
    		{
    			cout<<"Wrong Input"<<endl;
    		}
    		sum=sum+mark;
    
    	average=sum/numbof_student;
    	
    	if ((average>=3.5) &&(average<=4.0))
    	{
    	cout<<"Excellence";
    	}
    
    	else if ((average<=3.0) &&(average<=3.5))
    	{
    	cout<<"Good";
    	}
    
    	else if ((average<=2.0) &&(average<=3.0))
    	{
    	cout<<"Average";
    	}
    
    	else if (average<=2.0)
    	{
    	cout<<"Poor";
    	}
    	}
    
    	cout<<"\n\n\t\tUniversiti Pendidikan Sultan Idris";
    	cout<<"\n\n\t\tTeaching & Learning Evaluation Report";
    	cout<<"\n\nName : "<<lect_name<<endl;
    	cout<<"Subject Code : "<<subject<<endl;
    	cout<<"Average :"<<average<<endl;
    	cout<<"Status : "<<status<<endl;
    }
    i did coding for function, but blablabla... still error and error and then hard i try the simplest coding...

    can sumone?
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    You only have one main() function. The project requires three additional functions:

    Your program should at least have the following functions:-
    i. Function Average_Calculation – to calculate average mark
    ii. Function Status – to determine the status.
    iii. Function Display – display the result

    >> blablabla... still error and error

    And that is supposed to mean something? It looks like you don't care. Where is your code for the three functions Average_Calculation(), Status() and Display()?
     
  6. khelly

    khelly New Member

    Joined:
    Dec 1, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    I DO CARE...
    its late now,

    i had submit,

    yes, not above there, i did my function coding...

    i had done my assignment with non-stop working...

    without any help!
     
  7. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Well done! Let's hope you get a good result.
     
  8. khelly

    khelly New Member

    Joined:
    Dec 1, 2011
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    TQ, YES...

    tq for u help too...
     

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