fUNTIONS

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2004
Posts: 3
Reputation: MAPONYA is an unknown quantity at this point 
Solved Threads: 0
MAPONYA MAPONYA is offline Offline
Newbie Poster

fUNTIONS

 
0
  #1
Jul 30th, 2004
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 3
Reputation: MAPONYA is an unknown quantity at this point 
Solved Threads: 0
MAPONYA MAPONYA is offline Offline
Newbie Poster

Re: fUNTIONS

 
0
  #2
Jul 30th, 2004
#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
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 2
Reputation: Lerroy is an unknown quantity at this point 
Solved Threads: 0
Lerroy Lerroy is offline Offline
Newbie Poster

Re: fUNTIONS

 
0
  #3
Aug 2nd, 2004
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
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...
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 141
Reputation: meabed is on a distinguished road 
Solved Threads: 3
Team Colleague
meabed's Avatar
meabed meabed is offline Offline
Junior Poster

Re: fUNTIONS

 
0
  #4
Aug 2nd, 2004
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 ??
Real Eyes Realize Real Lies
My Resume
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 141
Reputation: meabed is on a distinguished road 
Solved Threads: 3
Team Colleague
meabed's Avatar
meabed meabed is offline Offline
Junior Poster

Re: fUNTIONS

 
0
  #5
Aug 2nd, 2004
look at this program ... and try to develop it to satisfy ur needs
Attached Files
File Type: c hw2_ron_goldin.c (3.1 KB, 9 views)
Real Eyes Realize Real Lies
My Resume
Reply With Quote Quick reply to this message  
Join Date: Aug 2004
Posts: 2
Reputation: Lerroy is an unknown quantity at this point 
Solved Threads: 0
Lerroy Lerroy is offline Offline
Newbie Poster

Re: fUNTIONS

 
0
  #6
Aug 10th, 2004
I'm Lerroy and this is how I've approached Maponya's Challenging problem.
  1. #include<iostream>
  2.  
  3. #include<iomanip>
  4.  
  5. using namespace std; //program uses std;
  6.  
  7. double readInput(); //function prototype
  8.  
  9. void calculatetotals(double,double &,int &,double &,int &); //function prototype
  10.  
  11. void showresults(double,int,double,int); //function prototype
  12.  
  13. void starlines(void); //function prototype
  14.  
  15. void main()
  16. {
  17. double put=0;
  18.  
  19. double failmark=0; //fail mark
  20.  
  21. double passmark=0; //pass mark
  22.  
  23. int fail=0; //failing students
  24.  
  25. int pass=0; //passing students
  26.  
  27.  
  28. put=readInput();
  29.  
  30. while put!=-999)
  31. {
  32. calculatetotals(put,passmark,pass,failmark,fail);
  33.  
  34. put=readInput();
  35. }
  36. showresults(passmark,pass,failmark,fail);
  37. return;
  38. }
  39.  
  40.  
  41. double readInput()
  42. {
  43. double mark;
  44.  
  45. cout<<"\nEnter student mark,-999 to stop : "; //prompt for student mark
  46.  
  47. cin>>mark; //reads mark
  48.  
  49. //the mark must not b = -999,musn't b -(<0) and musn't b >100(total mark).
  50.  
  51. while((mark!=-999 && mark<0)||mark>100)
  52. {
  53. cout<<"\nI think the test was out of 100..."<<endl; //if the user enters mark>50.
  54.  
  55. cout<<"\nStudent mark again please: "; //if wrong mark is entered
  56.  
  57. cin>>mark; //reads mark
  58. }
  59. return mark;
  60. }
  61.  
  62.  
  63. void calculatetotals(double mark,double &passmark,int &pass,double &failmark,int &fail)
  64.  
  65. {
  66. if(mark>=0 && mark<50) // for students who failed(got below 50)
  67. {
  68. fail++; //failed students.
  69. failmark+=mark; //fail mark.
  70. }
  71. if(mark>=50 && mark<=100) //for students who passed(got 50 and above ).
  72. {
  73. pass++; //passed students.
  74. passmark+=mark; //pass mark.
  75. }
  76. }
  77.  
  78.  
  79. void showresults(double Passmark,int Pass,double Failmark,int Fail)
  80. {
  81. cout<<fixed<<setprecision(2); //formatting the data type
  82.  
  83. cout<<endl;
  84.  
  85. cout<<"No. of students in a class : "<<Pass+Fail<<endl; //students in class
  86.  
  87. cout<<"\n\t\tResults :"<<endl;
  88.  
  89. starlines(); //call function starlines()
  90.  
  91. if(Pass!=0) //if pass = 0,is not calculated(average).
  92. {
  93. cout<<"\tPassed students : "<< Pass <<endl;
  94. }
  95. if(Fail!=0) //if fail = 0,is not calculated(average).
  96. {
  97. cout<<"\tFailed students : "<< Fail <<endl;
  98. }
  99.  
  100. starlines(); //call function starlines()
  101.  
  102. cout<<"\n\t\tAverages :"<<endl;
  103.  
  104. starlines(); //call function starlines()
  105.  
  106. if(Pass != 0)
  107. {
  108. cout<<"\tPass average :"<<(Passmark/Pass)<<endl;
  109. }
  110. if(Fail != 0)
  111. {
  112. cout<<"\tFail average :"<<(Failmark/Fail)<<endl;
  113. }
  114. starlines(); //call function starlines()
  115. cout << endl;
  116.  
  117. }
  118. //definition of the function starline.
  119. void starlines(void)
  120. {
  121. cout <<"\t*\a*\a*\a**************\a*\a*\a"<<endl;
  122.  
  123. cout <<endl;
  124. }
Last edited by Ancient Dragon; May 7th, 2008 at 12:56 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 1
Reputation: real_napster is an unknown quantity at this point 
Solved Threads: 0
real_napster real_napster is offline Offline
Newbie Poster

Re: fUNTIONS

 
0
  #7
May 7th, 2008
well i think that this is correct but what i have face it that the program shut down automaticaly without seeing the result

  1. #include<iostream>
  2.  
  3. #include<iomanip>
  4.  
  5. using namespace std; //program uses std;
  6.  
  7. double readInput(); //function prototype
  8.  
  9. void calculatetotals(double,double &,int &,double &,int &); //function prototype
  10.  
  11. void showresults(double,int,double,int); //function prototype
  12.  
  13. void starlines(void); //function prototype
  14.  
  15. int main()
  16. {
  17. double put=0;
  18.  
  19. double failmark=0; //fail mark
  20.  
  21. double passmark=0; //pass mark
  22.  
  23. int fail=0; //failing students
  24.  
  25. int pass=0; //passing students
  26.  
  27.  
  28. put=readInput();
  29.  
  30. while (put!=-999)
  31. {
  32. calculatetotals(put,passmark,pass,failmark,fail);
  33.  
  34. put=readInput();
  35. }
  36. showresults(passmark,pass,failmark,fail);
  37. return 0;
  38. }
  39.  
  40.  
  41. double readInput()
  42. {
  43. double mark;
  44.  
  45. cout<<"\nEnter student mark,-999 to stop : "; //prompt for student mark
  46.  
  47. cin>>mark; //reads mark
  48.  
  49. //the mark must not b = -999,musn't b -(<0) and musn't b >100(total mark).
  50.  
  51. while((mark!=-999 && mark<0)||mark>100)
  52. {
  53. cout<<"\nI think the test was out of 100..."<<endl; //if the user enters mark>50.
  54.  
  55. cout<<"\nStudent mark again please: "; //if wrong mark is entered
  56.  
  57. cin>>mark; //reads mark
  58. }
  59. return mark;
  60. }
  61.  
  62.  
  63. void calculatetotals(double mark,double &passmark,int &pass,double &failmark,int &fail)
  64.  
  65. {
  66. if(mark>=0 && mark<50) // for students who failed(got below 50)
  67. {
  68. fail++; //failed students.
  69. failmark+=mark; //fail mark.
  70. }
  71. if(mark>=50 && mark<=100) //for students who passed(got 50 and above ).
  72. {
  73. pass++; //passed students.
  74. passmark+=mark; //pass mark.
  75. }
  76. }
  77.  
  78.  
  79. void showresults(double Passmark,int Pass,double Failmark,int Fail)
  80. {
  81. cout<<fixed<<setprecision(2); //formatting the data type
  82.  
  83. cout<<endl;
  84.  
  85. cout<<"No. of students in a class : "<<Pass+Fail<<endl; //students in class
  86.  
  87. cout<<"\n\t\tResults :"<<endl;
  88.  
  89. starlines(); //call function starlines()
  90.  
  91. if(Pass!=0) //if pass = 0,is not calculated(average).
  92. {
  93. cout<<"\tPassed students : "<< Pass <<endl;
  94. }
  95. if(Fail!=0) //if fail = 0,is not calculated(average).
  96. {
  97. cout<<"\tFailed students : "<< Fail <<endl;
  98. }
  99.  
  100. starlines(); //call function starlines()
  101.  
  102. cout<<"\n\t\tAverages :"<<endl;
  103.  
  104. starlines(); //call function starlines()
  105.  
  106. if(Pass != 0)
  107. {
  108. cout<<"\tPass average :"<<(Passmark/Pass)<<endl;
  109. }
  110. if(Fail != 0)
  111. {
  112. cout<<"\tFail average :"<<(Failmark/Fail)<<endl;
  113. }
  114. starlines(); //call function starlines()
  115. cout << endl;
  116.  
  117. }
  118. //definition of the function starline.
  119. void starlines(void)
  120. {
  121. cout <<"\t*\a*\a*\a**************\a*\a*\a"<<endl;
  122.  
  123. cout <<endl;
  124. }
Last edited by Ancient Dragon; May 7th, 2008 at 12:56 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC