This is for devc++ version 5.11) Create a text file with following data to test your code. Read the following data from this text file: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63 Using the data above your output should be:(Check picture) Please use this as reference: // 1. declare an array of 20 scores and input the scores from a files scores.txt // 2. Declare the arrays GradeA, GradeB, GradeC, GrddeD and Failed // 3. Declare the necessary counters // 4. Write the code to read these scores and add the scores greater than 90 to array called GradeA //Write the code to read these scores and add the scores greater than 80 less 90 to array called GradeB //Write the code to read these scores and add the scores greater than 70 less than 80 to array called GradeC //Write the code to read these scores and add the scores greater than 60 less then 70 to array called GradeD ////Write the code to read these scores and add all the rest of scores to array called Failed //5. Then dosplay all these arrays const int SIZE =20; #include using namespace std; #include int main(){ ifstream inputFile; double scores[SIZE]; int scoreCounter=0; //Declare the 5 arrays here double gradeA[SIZE]; int counterA=0; double gradeB[SIZE]; int counterB=0; double gradeC[SIZE]; int counterC=0; double gradeD[SIZE]; int counterD=0; double gradeF[SIZE]; int counterF=0;inputFile.open("Scores.txt"); while (!inputFile.eof() ){ inputFile >> scores[scoreCounter]; scoreCounter++; } inputFile.close(); // Add the code here to put the scores into those 5 arrays for (int i = 0; i= 90){ gradeA[counterA] = scores[i]; counterA ++; } else if (scores[i] >= 80){ gradeB[counterB] = scores[i]; counterB ++; } else if (scores[i] >= 70){ gradeC[counterC] = scores[i]; counterC ++; } else if (scores[i] >= 60){ gradeD[counterD] = scores[i]; counterD ++; } else { gradeF[counterF] = scores[i]; counterF ++; } } //Print the contents of scores array for (int i=0;i
(This is for devc++ version 5.11)
Create a text file with following data to test your code. Read the following data from this text file:
Johnson 85 83 77 91 76
Aniston 80 90 95 93 48
Cooper 78 81 11 90 73
Gupta 92 83 30 69 87
Blair 23 45 96 38 59
Clark 60 85 45 39 67
Kennedy 77 31 52 74 83
Bronson 93 94 89 77 97
Sunny 79 85 28 93 82
Smith 85 72 49 75 63
Using the data above your output should be:(Check picture)
Please use this as reference:
// 1. declare an array of 20 scores and input the scores from a files scores.txt
// 2. Declare the arrays GradeA, GradeB, GradeC, GrddeD and Failed
// 3. Declare the necessary counters
// 4. Write the code to read these scores and add the scores greater than 90 to array called GradeA
//Write the code to read these scores and add the scores greater than 80 less 90 to array called GradeB
//Write the code to read these scores and add the scores greater than 70 less than 80 to array called GradeC
//Write the code to read these scores and add the scores greater than 60 less then 70 to array called GradeD
////Write the code to read these scores and add all the rest of scores to array called Failed
//5. Then dosplay all these arrays
const int SIZE =20;
#include <iostream>
using namespace std;
#include <fstream>
int main(){
ifstream inputFile;
double scores[SIZE];
int scoreCounter=0;
//Declare the 5 arrays here
double gradeA[SIZE];
int counterA=0;
double gradeB[SIZE];
int counterB=0;
double gradeC[SIZE];
int counterC=0;
double gradeD[SIZE];
int counterD=0;
double gradeF[SIZE];
int counterF=0;inputFile.open("Scores.txt");
while (!inputFile.eof() ){
inputFile >> scores[scoreCounter];
scoreCounter++;
}
inputFile.close();
// Add the code here to put the scores into those 5 arrays
for (int i = 0; i<SIZE; i++){
if (scores[i] >= 90){
gradeA[counterA] = scores[i];
counterA ++;
}
else if (scores[i] >= 80){
gradeB[counterB] = scores[i];
counterB ++;
}
else if (scores[i] >= 70){
gradeC[counterC] = scores[i];
counterC ++;
}
else if (scores[i] >= 60){
gradeD[counterD] = scores[i];
counterD ++;
}
else {
gradeF[counterF] = scores[i];
counterF ++;
}
}
//Print the contents of scores array
for (int i=0;i<SIZE;i++)
cout << scores[i]<<" ";
cout << endl;
cout << endl << "The value of gradeA = ";
for (int i = 0; i<counterA; i++){
cout << gradeA[i] <<",";
}
cout << endl << "The value of gradeB = ";
for (int i = 0; i<counterB; i++){
cout << gradeB[i] <<",";
}
cout << endl << "The value of gradeC = ";
for (int i = 0; i<counterC; i++){
cout << gradeC[i] <<",";
}
cout << endl << "The value of gradeD = ";
for (int i = 0; i<counterD; i++){
cout << gradeD[i] <<",";
}
cout << endl << "The value of gradeF = ";
for (int i = 0; i<counterF; i++){
cout << gradeF[i] <<",";
}
}
Step by step
Solved in 3 steps with 1 images