954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

fUNTIONS

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.

MAPONYA
Newbie Poster
3 posts since Jul 2004
Reputation Points: 10
Solved Threads: 0
 

#include
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"<>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

MAPONYA
Newbie Poster
3 posts since Jul 2004
Reputation Points: 10
Solved Threads: 0
 
#include 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"<>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

7b

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...

Lerroy
Newbie Poster
2 posts since Aug 2004
Reputation Points: 10
Solved Threads: 0
 

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 ??

meabed
Junior Poster
Team Colleague
139 posts since May 2004
Reputation Points: 55
Solved Threads: 3
 

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

Attachments hw2_ron_goldin.c (3.15KB)
meabed
Junior Poster
Team Colleague
139 posts since May 2004
Reputation Points: 55
Solved Threads: 3
 

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;
  }
Lerroy
Newbie Poster
2 posts since Aug 2004
Reputation Points: 10
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

#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;
}
real_napster
Newbie Poster
1 post since May 2008
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You