| | |
fUNTIONS
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2004
Posts: 3
Reputation:
Solved Threads: 0
Write a C++ program ,that uses modularisation.
The program allows the end user to enter a test mark which is converted into persantage by a particular funtion, the test mark is returned to main(),
another funtion is called which detemines whether the student passed or failed if ist a pass increment number of students who passed do like wise for fail, the funtion must also determine the average pass rate and average fail rate.
The last funtion displays the results in a tabular format,
it displays the total number of students ,number of failures ,num,ber of passes and there averages.
The program allows the end user to enter a test mark which is converted into persantage by a particular funtion, the test mark is returned to main(),
another funtion is called which detemines whether the student passed or failed if ist a pass increment number of students who passed do like wise for fail, the funtion must also determine the average pass rate and average fail rate.
The last funtion displays the results in a tabular format,
it displays the total number of students ,number of failures ,num,ber of passes and there averages.
•
•
Join Date: Jul 2004
Posts: 3
Reputation:
Solved Threads: 0
#include <iostream>
using namespce std;
void ReadInput(); //this funtion allows the user to enter the test mark.
{
duoble marks; //student mark
mark *=0.5 //mark converted to persantage if the test is out of 50.
cout<<"ENTER STUDENT MARK"<<endl;
cin>>mark;
return mark;
}
double calulateResults(double);
void showResults(doule);
int main()
{
readInput();
while(mark !=-999){
calculateResults(mark);
showResults(double);
readInput();
}
return 0;
}
calculateResults(double mark)
{
double mark;
double calculateResults(double); //this
using namespce std;
void ReadInput(); //this funtion allows the user to enter the test mark.
{
duoble marks; //student mark
mark *=0.5 //mark converted to persantage if the test is out of 50.
cout<<"ENTER STUDENT MARK"<<endl;
cin>>mark;
return mark;
}
double calulateResults(double);
void showResults(doule);
int main()
{
readInput();
while(mark !=-999){
calculateResults(mark);
showResults(double);
readInput();
}
return 0;
}
calculateResults(double mark)
{
double mark;
double calculateResults(double); //this
•
•
Join Date: Aug 2004
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by MAPONYA
#include <iostream>
using namespce std;
void ReadInput(); //this funtion allows the user to enter the test mark.
{
duoble marks; //student mark
mark *=0.5 //mark converted to persantage if the test is out of 50.
cout<<"ENTER STUDENT MARK"<<endl;
cin>>mark;
return mark;
}
double calulateResults(double);
void showResults(doule);
int main()
{
readInput();
while(mark !=-999){
calculateResults(mark);
showResults(double);
readInput();
}
return 0;
}
calculateResults(double mark)
{
double mark;
double calculateResults(double); //this
Hi Maponya, this is Lerroy and I would like to have your permission to see if this program can run because I'm also suffering from its difficult situation.HELP PLZ...
k .. continue what u r doing ?? what is the other ****tion that u want .. and write it .. i dont see any something hard in this code ..
if u have say where r u stuck ??
if u have say where r u stuck ??
Real Eyes Realize Real Lies
My Resume
My Resume
look at this program ... and try to develop it to satisfy ur needs
Real Eyes Realize Real Lies
My Resume
My Resume
•
•
Join Date: Aug 2004
Posts: 2
Reputation:
Solved Threads: 0
I'm Lerroy and this is how I've approached Maponya's Challenging problem.
C++ Syntax (Toggle Plain Text)
#include<iostream> #include<iomanip> using namespace std; //program uses std; double readInput(); //function prototype void calculatetotals(double,double &,int &,double &,int &); //function prototype void showresults(double,int,double,int); //function prototype void starlines(void); //function prototype void main() { double put=0; double failmark=0; //fail mark double passmark=0; //pass mark int fail=0; //failing students int pass=0; //passing students put=readInput(); while put!=-999) { calculatetotals(put,passmark,pass,failmark,fail); put=readInput(); } showresults(passmark,pass,failmark,fail); return; } double readInput() { double mark; cout<<"\nEnter student mark,-999 to stop : "; //prompt for student mark cin>>mark; //reads mark //the mark must not b = -999,musn't b -(<0) and musn't b >100(total mark). while((mark!=-999 && mark<0)||mark>100) { cout<<"\nI think the test was out of 100..."<<endl; //if the user enters mark>50. cout<<"\nStudent mark again please: "; //if wrong mark is entered cin>>mark; //reads mark } return mark; } void calculatetotals(double mark,double &passmark,int &pass,double &failmark,int &fail) { if(mark>=0 && mark<50) // for students who failed(got below 50) { fail++; //failed students. failmark+=mark; //fail mark. } if(mark>=50 && mark<=100) //for students who passed(got 50 and above ). { pass++; //passed students. passmark+=mark; //pass mark. } } void showresults(double Passmark,int Pass,double Failmark,int Fail) { cout<<fixed<<setprecision(2); //formatting the data type cout<<endl; cout<<"No. of students in a class : "<<Pass+Fail<<endl; //students in class cout<<"\n\t\tResults :"<<endl; starlines(); //call function starlines() if(Pass!=0) //if pass = 0,is not calculated(average). { cout<<"\tPassed students : "<< Pass <<endl; } if(Fail!=0) //if fail = 0,is not calculated(average). { cout<<"\tFailed students : "<< Fail <<endl; } starlines(); //call function starlines() cout<<"\n\t\tAverages :"<<endl; starlines(); //call function starlines() if(Pass != 0) { cout<<"\tPass average :"<<(Passmark/Pass)<<endl; } if(Fail != 0) { cout<<"\tFail average :"<<(Failmark/Fail)<<endl; } starlines(); //call function starlines() cout << endl; } //definition of the function starline. void starlines(void) { cout <<"\t*\a*\a*\a**************\a*\a*\a"<<endl; cout <<endl; }
Last edited by Ancient Dragon; May 7th, 2008 at 12:56 pm. Reason: add code tags
•
•
Join Date: May 2008
Posts: 1
Reputation:
Solved Threads: 0
well i think that this is correct but what i have face it that the program shut down automaticaly without seeing the result
C++ Syntax (Toggle Plain Text)
#include<iostream> #include<iomanip> using namespace std; //program uses std; double readInput(); //function prototype void calculatetotals(double,double &,int &,double &,int &); //function prototype void showresults(double,int,double,int); //function prototype void starlines(void); //function prototype int main() { double put=0; double failmark=0; //fail mark double passmark=0; //pass mark int fail=0; //failing students int pass=0; //passing students put=readInput(); while (put!=-999) { calculatetotals(put,passmark,pass,failmark,fail); put=readInput(); } showresults(passmark,pass,failmark,fail); return 0; } double readInput() { double mark; cout<<"\nEnter student mark,-999 to stop : "; //prompt for student mark cin>>mark; //reads mark //the mark must not b = -999,musn't b -(<0) and musn't b >100(total mark). while((mark!=-999 && mark<0)||mark>100) { cout<<"\nI think the test was out of 100..."<<endl; //if the user enters mark>50. cout<<"\nStudent mark again please: "; //if wrong mark is entered cin>>mark; //reads mark } return mark; } void calculatetotals(double mark,double &passmark,int &pass,double &failmark,int &fail) { if(mark>=0 && mark<50) // for students who failed(got below 50) { fail++; //failed students. failmark+=mark; //fail mark. } if(mark>=50 && mark<=100) //for students who passed(got 50 and above ). { pass++; //passed students. passmark+=mark; //pass mark. } } void showresults(double Passmark,int Pass,double Failmark,int Fail) { cout<<fixed<<setprecision(2); //formatting the data type cout<<endl; cout<<"No. of students in a class : "<<Pass+Fail<<endl; //students in class cout<<"\n\t\tResults :"<<endl; starlines(); //call function starlines() if(Pass!=0) //if pass = 0,is not calculated(average). { cout<<"\tPassed students : "<< Pass <<endl; } if(Fail!=0) //if fail = 0,is not calculated(average). { cout<<"\tFailed students : "<< Fail <<endl; } starlines(); //call function starlines() cout<<"\n\t\tAverages :"<<endl; starlines(); //call function starlines() if(Pass != 0) { cout<<"\tPass average :"<<(Passmark/Pass)<<endl; } if(Fail != 0) { cout<<"\tFail average :"<<(Failmark/Fail)<<endl; } starlines(); //call function starlines() cout << endl; } //definition of the function starline. void starlines(void) { cout <<"\t*\a*\a*\a**************\a*\a*\a"<<endl; cout <<endl; }
Last edited by Ancient Dragon; May 7th, 2008 at 12:56 pm. Reason: add code tags
![]() |
Similar Threads
- Winsock Multi-Client Servers (C++)
- problems with reading random access line from a file (C++)
- fstream Tutorial (C++)
- Tic-Tac-Toe (C++)
- Another Program Launching mine (C++)
- how to make colors (C++)
- How to write a header file (C++)
- Debugging Link errors (C)
- How to incorporate Database into C++ ? (C++)
Other Threads in the C++ Forum
- Previous Thread: Visual C++ Transparency
- Next Thread: Windows Message loop
| Thread Tools | Search this Thread |
api array arrays based binary bitmap c++ c/c++ calculator char char* class code coding compile console conversion count data database delete deploy desktop developer dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg sorting string strings temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





