i need a code about functions

1. Write a program that uses a function which computes for the Prelim Grade.

With the following details:
a. Quizzes ( Average of 3)
b. Exercises ( Average of 3 )
c. Class Participation
d. Class Standing
a. Class Standing (CS)= 50%( Average Quiz) + 30% (Class Participation) + 20%(Average Assignment)
e. Prelim Exam
f. Prelim Grade
a.

Requirements:
1. Create one main program (.cpp)
2. 3 functions are needed for the exercise. (.h)
a. Average function for Quizzes and Exercise (we have completed this in our previous exercise)
b. Function on Class Standing ( see formula above)
c. Function on the Prelim Grade ( see formula above)



 Make sure to turn in 4 files - main program (.cpp) and Function (.h)






Please take note the output that - Quiz 1 , Quiz 2 , Quiz 3 , Exercise 1, Exercise 2, Exercise 3 , Class Participation , and Prelim Exam are user input.
Have you written anything?
Write a program
No.


Why not write it yourself? We aren't going to do your homework for you.
Well said Lumpkin, it is not right we do your homework because if you do not pay attention in class it should be the case you pay for your carelessness.

Next the homework is pretty straight-forward why not at least attempt it and show us the source code that way we can tell you the mistakes you made.
This not a homework. I am just asking this help for my friend. Please.....

Tis is the only code i have
#include <iostream>
#include "quiz.h"
#include "exercise.h"
int main ()
{
int a, b, c;
std::cout << ("Quizes(q) or Exercises(e)?: ");
char input;
std::cin >> input;
if(input == 'q')
{
std::cout << "Input Quizzes\n";
std::cout << ("Quiz 1:\t");
std::cin >> c ;
std::cout << ("Quiz 2:\t");
std::cin >> b ;
std::cout << ("Quiz 3:\t");
std::cin >> a;
std::cout << ("Average Quizzes:") << (average_quiz(a, b, c)) << ("\n\n");
}
if(input == 'e')
{
std::cout << ("Input Exercises\n");
std::cout << ("Exercise 1:\t") ;
std::cin >> c ;
std::cout << ("Exercise 2:\t") ;
std::cin >> b ;
std::cout << ("Exercise 3:\t");
std::cin >> a;
std::cout << ("Average Exercises:") << (average_exercise(a, b, c)) << ("\n\n");
}
else
{
std::cout << ("Invalid option: ") << (input) << std::endl;
return(-1);
}
std::cin.get();
return 0;
}
closed account (3qX21hU5)
Well for one I would suggest you move this to the proper forum (Beginners Forum would probably be best) and also I would suggest going through the tutorial on this site starting wherever you feel most comfortable (If you feel comfortable enough with everything before the functions tutorial then start there).

Anyways wish you the best of luck and next time you might wanna lead with what you have already and give more information on what you are having trouble with exactly. Go into detail on everything, the more information you provide us the more we can help. It also shows us that you are willing to actually learn and do the work and we will be more likely to help you.

Because to be honest there is one thing most programmers and people in general hate. It is when people try to pass of their work onto someone else, or seem unwilling to actually learn what the code is doing and just want someone to give them the answer. Remember we are here to guide you through learning to solve your problems, not solve them for you (Unless you are paying us to do so ;p)

Also we aren't stupid we know this is some sort of homework that you need to do because it is the standard homework question we see a hundred times a day here ;p.

So just remember be very thorough in what you have done already and what you don't understand.
Last edited on
so what is the next step for me to do?
closed account (3qX21hU5)
I just told you.
Here be nice he's new.

@hummer1 sry I can't help, I'm a beginner. I Donno much
hi i am done with my code but there is an error. I hope you can help me with this. IT SAYS "CS" undeclared use this function first

HERE IS THE CODE;


#include <iostream>
using namespace std;
int ave (int c, int b, int a);

int main ()
{

int d;
int c;
int b;
int a;
cout << "Input Quizzes\n";
cout << "Quiz 1:\t" ;
cin >> c ;
cout << "Quiz 2:\t" ;
cin >> b ; cout << "Quiz 3:\t" ;
cin >> a; { d=(c+b+a)/3;
cout << "Average Quizzes:" << d << "\n\n";
int d;
int c;
int b;
int a;
cout << "Input Exercises\n";
cout << "Exercise 1:\t" ;
cin >> c ;
cout << "Exercise 2:\t" ;
cin >> b ;
cout << "Exercise 3:\t" ;
cin >> a; { d=(c+b+a)/3;
cout << "Average Exercises:" << d << "\n\n";
cout <<"Input Class Participation:\t" ;
cin >> d ;
cout<< endl;

CS=(Average Quiz)*.50 + (Class Participation)*.30 + (Average Assignment)*.20;
cout <<"Prelim Exam:\t" ;

PG=(2*CS)+PE/3;
cout<<" " <endl<<Prelim Grade:"<<PG<<"\n";
}
system("pause");
return 0;
}
system("pause");
return 0;
}
It's as it says; about halfway through your function you are trying to assign to a variable called 'CS' but you haven't declared it anywhere.
http://www.cplusplus.com/articles/jEywvCM9/

This not a homework. I am just asking this help for my friend. Please.....
Ya, and I'm the queen of England.

Why exactly are you returning 0 2 times?

And system commands are bad practice. Don't worry about it much as this is just homework, I'm just telling you for future references.

Why are you declaring
1
2
3
4
int d;
int c;
int b;
int a; 
two times? That should give you an error. And PG is also not defined.
Last edited on
The double declaration does not give a compilation error due to the explicit braced scopes, which the non-indented and -highlighted code makes hard to spot.
The double declaration does not give a compilation error due to the explicit braced scopes

Ha ha! I guess every obfuscation genius starts with a homework.
Either way, I feel it's bad practice to declare those variables so close to eachother, you might forget which is which.
Topic archived. No new replies allowed.