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.

Recommended Answers

All 6 Replies

#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 fucktion that u want .. and write it .. i dont see any something hard in this code ..
if u have say where r u stuck ??

look at this program ... and try to develop it to satisfy ur needs

I'm Lerroy and this is how I've approached Maponya's Challenging problem.

#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;
  }

well i think that this is correct but what i have face it that the program shut down automaticaly without seeing the result

#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;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.