hey , i got this homework i tried many times to solve with no result , can some 1 guide me with some instructions , we program in code blocks only , can i found some one here give me a hand with this plz ..
I agree it is straight forward. And we cant really help you without knowing what you are having trouble with. Also remmber wheb you post code to these forums use the codetags feature (the <> off to the right when replying)
Rewrite it yourself? Don't expect other people to do your work for you. He actually answered your question for you and you dont "have the time" to correct a few errors? Your not going to learn by copy and pasting you know.
We see posts here everyday saying they have 5 finals and even more homework so they don't have time but maybe if they started on the assignments before the last minute they would have time to do it ;p. Professors don't give out a final and say "hey you got 2 days to get it done now do it".
i said before i still noob and i dont have the time now after i finish my final exams the day after tommorw i will learn this languge its not my specailst , but i like it .
This is not a homework answer site. If someone essentially gave you the answer and you still can't figure out a few errors, then I really doubt you've been doing the work before now either. Good Luck.
constint studentLimit = 5;
int main ()
{
int input = 0;
int studentCount = 0;
int minGrade = INT_MAX;
int maxGrade = INT_MIN;
double grades[studentLimit];
do
{
cout << "Enter a valid grade <range is 0 to 100> (Enter -1 to exit)" << endl;
cin >> input;
if (input != -1 and (input < 0 or input > 100))
cout << "Please enter a valid grade <range is 0 to 100>" << endl;
elseif (studentCount > studentLimit)
cout << "Student limit reached...";
else
{
grades[studentCount] = input;
if (input < minGrade and input >= 0)
minGrade = input;
if (input > maxGrade and input <= 100)
maxGrade = input;
studentCount++;
}
}
while (input != -1 and studentCount < studentLimit);
// you can exit here if you want
if (input == -1)
{
cout << "Exiting Program...";
}
thank you all for this advices now iam trying step by step to write this program i start with the minimum and maximum grade i write this code , any advices :
#include <iostream>
usingnamespace std;
int i=1;
double grades[100]={};
double minimun(double a[],int 100)
{
double min=a[0];
for (i;i<=100;i++)
{
if (min<a[i])
{
min=a[i];
}
return min;
}
}
int main ()
{
int max=grades[0];
for (i;i<=100;i++)
{
if (grades[i]>max)
{
cout <<"the maximum grade=" << max=grades[i];
}
}
cout << "the minimum grade=" << minimum(grades,100)
return 0;
}
/*|7|error: expected ',' or '...' before numeric constant|
|In function 'double minimun(double*, int)':|
|12|warning: statement has no effect|
|In function 'int main()':|
|25|warning: statement has no effect
||29|error: no match for 'operator=' in '((std::basic_ostream<char, std::char_traits<cha...
|33|error: 'minimum' was not declared in this scope|
|35|error: expected ';' before 'return'|
||=== Build finished: 4 errors, 2 warnings ===| */
what these statments in line 6 and 7 , what they represent ?
/* part 2 of my program ,
this program reads the grades and specify the number of
grades , average , number of passing ,
failing grades .*/
#include <iostream>
usingnamespace std;
int main ()
{
double input;
double grades;
int i;
int sum=0 ,pass=0 , fail=0;
for (i=0;i<100;i++)
{
cout << "Enter the grade please(-1 to end)=" ;
cin >> input;
if (input >=0 && input <=100 && input !=-1)
{
sum=sum+input;
grades++;
if (input >=50)
{
pass++;
}
else
{
fail++;
}
}
elseif (input == -1)
{
cout << "The average of the grades=" << sum/grades ;
cout << "\nThe number of grades u enterd=" << grades ;
cout <<"\nThe number of passing grades=" << pass ;
cout << "\nThe number of failing grades=" << fail ;
break ;
}
else
{
cout << "error, grade must be between (0 and 100)\n" ;
}
}
return 0;
}
its look like good code i compile and run it with no errors or warning , any advices , is this good code for such full program ?
See I find it completely stupid that professors would "not allow" students to use C++11. Shows that a lot of professors are stuck in the old ways and are holding back students because of it.
Also the program looks good for what you have but your missing some things like the median of the grades, the average grade, use arrays and some other things. Also you your first part has some mistakes also. But this is a very good start always start with what you know you can do then add the stuff that you are having trouble with step by step. Make little changes and then make sure they compile.
Also what IDE and Compiler are you using? If you are using the old bloodshed Dev C++ I would recommend upgrading to either the new orwell Dev C++ (I think thats the name) or code::blocks or Visual Studio Express
zereo,i wish he was a professor , or a doctor he shorten the material(c++ programing) thats why i have difficulties .
now all i need little support in:
1-how sorting grades in array and use it in function and call an array function.
2-how to find the median .
http://www.mathsisfun.com/median.html
Sort the values.
If there are an odd number of values, pick the middle one.
If there are an even number of values, pick the middle two, and take their average.
chervil ty for ur support , but i alrdy know if odd the middle number , and if ever its the sum of the both middle numbers , but how can i specify this mid number , because the use will enter the number of grades ?
Here is a quick example of how to find the median. I removed some of the code so I don't just give you the answer but it should help you with a general idea of how to do it.
#include <iostream>
#include <vector>
#include <algorithm>
usingnamespace std;
double CalcMedian(vector<double> scores);
int main()
{
vector<double> grades;
double grade;
double median;
while (cin >> grade)
{
grades.push_back(grade);
}
median = CalcMedian(grades);
cout << median << endl;
}
double CalcMedian(vector<double> scores)
{
double median;
vector<double>::size_type size = scores.size();
// Removed so you can figure it out. (HINT: You need to sort the vector or other container)
if (size % 2 == 0)
{
// Removed so you can figure it out
}
else
{
// removed so you can figure it out
}
return median;
}