| | |
I need your help with functions
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2007
Posts: 17
Reputation:
Solved Threads: 0
I need to write program with five different functins. Teacher wants to input the names and exam marks for her students. She wants to determine symbol (A-F) she should assign to each. She wants to display the symbol as well as an appropriate message. Finally she would like to display the highest mark as well as the averae mark of the class. So far I did this:
1st function to input nameAndMark
2nd function to determine the symbol
3rd function to display message
4th main function
But its all I could do. Please help me. Tell me what I am doing wrong so far that my functions don't work properly?
Need urgante help. Today its my finale day.
1st function to input nameAndMark
C++ Syntax (Toggle Plain Text)
void InputName(string & nameP, int & markP) { cout << "Type the student's name: "; cin >> nameP; cout << "Enter the stuedent's mark: "; cin >> markP; }
2nd function to determine the symbol
C++ Syntax (Toggle Plain Text)
char symbol(char symbolP, int markP) { if (markP > 0 && markP < 40) return symbolP = 'F'; else if (markP >= 40 && markP < 50) return symbolP = 'E'; else if (markP >= 50 && markP < 60) return symbolP = 'D'; else if (markP >= 60 && markP < 70) return symbolP = 'C'; else if (markP >= 70 && markP < 80) return symbolP = 'B'; else if (markP >= 80 && markP <= 100) return symbolP = 'A'; else cout << "The range of mark is 0 - 100" << endl; }
3rd function to display message
C++ Syntax (Toggle Plain Text)
void displayMessage(char symbolP, string nameP) { switch(symbolP) { case 'F': cout << "Unfortunately you will have to repeat the course, " << nameP << "." << endl; break; case 'E': cout << "You nearly passed. Keep trying, " << nameP << "." << endl; break; case 'D': cout << "Congratulations! You passed, " << nameP << "." << endl; break; case 'C': cout << "Congratulations! You got 60%, " << nameP << "." << endl; break; case 'B': cout << "Well done! Congratulations, " << nameP << "." << endl; break; case 'A': cout << "Excellent! Congratulations, " << nameP << "." << endl; break; } }
4th main function
C++ Syntax (Toggle Plain Text)
int main() { string name; int mark, totalMark, highestMark; float averagMark; char sym; totalMark = 0; for (int i = 1; i <= 3; i++) { InputName( name, mark); symbol( sym, mark); displayMessage(sym, name); } cout << endl; cout << "Highest mark is: "; return 0; }
But its all I could do. Please help me. Tell me what I am doing wrong so far that my functions don't work properly?
Need urgante help. Today its my finale day.
You have to write two more functions to compute the total marks and the highest marks.
I can suggest the prototypes as:
Its really simple to implement these functions. Hope that helps.
I can suggest the prototypes as:
C++ Syntax (Toggle Plain Text)
void totalmarks( int ¤tTotal, int &marks ); void highestmarks( int ¤tHighest, int marks );
Its really simple to implement these functions. Hope that helps.
for (int i = 1; i <= 3; i++)
{
InputName( name, mark);
symbol( sym, mark);
displayMessage(sym, name);
}If you don't wish to use the return value, then you will need to pass sym by reference, ie
char symbol(char & symbolP, int markP) Last edited by Bench; May 24th, 2007 at 7:39 am.
¿umop apisdn upside down? ![]() |
Similar Threads
- VB's Left, Right, Mid Functions in C++? (C++)
- User defined functions (C++)
- Double Linked Lists and Functions required (C++)
- How to write FNVAL functions (Java)
- I dont see any difference between these 2 functions, DO YOU? (C)
- access Digital Camera Functions (C++)
Other Threads in the C++ Forum
- Previous Thread: Randomly Generated Network
- Next Thread: C++ A little homework help, Thanks very much for the last assistance
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion convert count data database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game generator getline google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number output parameter pointer problem program programming project proxy python random read recursion recursive return sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





