C++ programming Students from CSCE 206 attended a test that had two versions of
ID: 3761001 • Letter: C
Question
C++ programming
Students from CSCE 206 attended a test that had two versions of the exam, Version_A, and Version_B.
15 students received version A, and their scores are 52, 86, 95, 23, 78, 89, 52, 81, 97, 45, 35, 84, 75, 94, 26 8 students received version B, and we don’t know their scores. Hence, ask the user to enter scores for 8 students [ Validation: All scores must be > 10 ]
Create two arrays Version_A, and Version_B, and populate them with the scores accordingly. The program must use Arrays and loops.
Compute: Version A mean score
Version B mean score
Mean score, when both version A and B scores are combined
Least score, when both version A and B scores are combined
Highest score, when both version A and B scores are combined
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int version_a[15] = {52, 86, 95, 23, 78, 89, 52, 81, 97, 45, 35, 84, 75, 94, 26};
int version_b[8];
for(int i=0;i<8;i++)
{
cout << "Input score number " << i+1 << " for version-b : ";
while(true)
{
cin >> version_b[i];
if(version_b[i]<=10)
{
cout << "Score should be greater than 10. Please input again: ";
continue;
}
else
break;
}
}
int suma = 0,sumb = 0;
int min = version_a[0],max = version_a[0];
for(int i=0;i<15;i++)
{
suma = suma + version_a[i];
if(version_a[i]>max)
max = version_a[i];
if(version_a[i]<min)
min = version_a[i];
}
for(int i=0;i<8;i++)
{
sumb = sumb + version_b[i];
if(version_b[i]>max)
max = version_b[i];
if(version_b[i]<min)
min = version_b[i];
}
cout << "Version-A mean score : " << suma*1.0/15 << endl;
cout << "Version-B mean score : " << sumb*1.0/8 << endl;
cout << "Version-A Version-B combined mean score : " << (suma+sumb)*1.0/23 << endl;
cout << "Version-A Version-B combined least score : " << min << endl;
cout << "Version-A Version-B combined highest score : " << max << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.