ANY ONE WHO CAN PLEASE HELP........


Design and write a C++ program for the problem given below. Apply the rules of good programming style by making your program modular, and using parameters and local variables in subprograms or functions. Add comments where necessary for each function. Use meaningful variable names. Your program should be user friendly.

A grade 12 class wrote a test in information technology which counted 50 marks. Their teacher wants to find out how many pupils got a mark between 0 and 49 percent (i.e. how many pupils failed), and how many got a mark of 50 percent and more (i.e. how many pupils passed the test). He also wants to determine the average mark of those who failed and the average mark of those who passed. Your task is to write a C++ program to do this. The marks should be entered until -999 is typed in and at the end the two totals calculated as well as the two averages have to displayed.
Your program should make use of the following 3 functions to solve the problem:

readInput( ): In this function, the end-user(teacher) should be prompted for a mark to be entered. After the mark has been captured it should be send back to the calling function, namely main( )

calculateTotals( ): Calculates the totals up to that point. In this function the mark that has just been read in, must be investigated to see which totals should be updated. It will be necessary to update two totals every time: One (1)should be added to the number of pupils in the specific group, and the mark should be added to the total of marks in that group (because later you have to calculate the average). You will need one or more if statements

showResults( ): displays the number of pupils in each group as well as the average mark for each group. However if the number of pupils in the group is zero, the average should not be calculated and displayed.

Hello,

I moved this request out of the Tutorial section... the thread was misplaced, and belongs here.

Second, we do not do your homework. We will assist with your posted program, helping you work the kinks out. But we will not do your assignment, that is unethical for you to ask us to, and unethical for us to supply it to you.

PLease send us your code. If you do not know where to start, send us your psuedo code. Let's work on this and learn how to do it, not how to get it done without doing it.

Christian

it's all about using the functions to writte a program wich will prompt the end user to enter marks.
calculate the number of students who failed and also calculate the marks of students who failed, then the average mark of students who failed, the same with students who passed.
and output the number of failed students and their average mark, the number of passed students and their average mark.

That's seriously easy, and you seriously don't need to be asking people to write your code. Though, should you get started and have a bug or a specific question, then I will be more than happy to help if I am able. :)

ok here it is!


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

This question has already been answered. Start a new discussion instead.