1) Class grades -Write a program that performs the following: #include <iostream
ID: 3610587 • Letter: 1
Question
1) Class grades-Write a program that performs the following:
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
int quiz1[10], quiz2[10],finalExam[10],lowest=20, highest=100;
int range=(highest-lowest)+1;
srand((unsigned)time(0));
for(inti=0; i<10; i++)
{
int x = lowest+int(range*rand()/(RAND_MAX +1.0));
quiz1[i]=x;}
for(inti=0; i<10; i++)
{
int y = lowest+int(range*rand()/(RAND_MAX +1.0));
quiz2[i]=y;
}
for(inti=0; i<10; i++)
{
int z = lowest+int(range*rand()/(RAND_MAX +1.0));
finalExam[i]=z;
}
int finalGrade[10];
for(inti=0;i<10;i++)
{
finalGrade[i]=0.3*quiz1[i]+0.3*quiz2[i]+0.4*finalExam[i];
}
int min=100;
int max=0;
int sum=0;
for (inti=0;i<10;i++)
{
if (finalGrade[i]>max)
{
max=finalGrade[i];
}
if (finalGrade[i]<min)
{
min=finalGrade[i];
}
sum=sum+finalGrade[i];
}
int oldAverage=sum/10;
cout<<"Lowest Gradeis:"<<min<<endl;
cout<<"Highest Gradeis:"<<max<<endl;
cout<<"Averageis:"<<oldAverage<<endl;
int newGrade[10]; //from here part e starts,but it is wrong so plz I want a correctanswer
double k=2.3026*log(0.78);
double l=2.3026*log(0.01*oldAverage);
for (inti=0;i<10;i++)
{
newGrade[i]=100*pow(finalGrade[i]/100,k/l);
}
return 0;
}
Explanation / Answer
please rate - thanks I believe your math is correct. However I don't know anythingabout logs so I assume the 2.3026 is correct. The problem is your types, you are using int instead ofdouble. You also didn't make 10 a constate named SIZE (Icorrected that) I changed some types and always get a newAverage that would roundto 78 (I don't know if the math makes it exactly 78) hope this helps, or at least gets you closer to your solution (Iadded a system("pause"); for my compiler, you may need to get ridof it) #include #include #include #include #define SIZE 10 using namespace std; int main() { int quiz1[SIZE], quiz2[SIZE], finalExam[SIZE],lowest=20,highest=100; int range=(highest-lowest)+1; srand((unsigned)time(0)); for(int i=0; iRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.