When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
7 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
This is the code btw:
`
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
using namespace std;
int main(){
// variables and array
double input, sumAverage;
int count {0};
double arrSum[120];
// prompt
cout << "Enter the first score or -999 to end input: ";
// logic below
for(int i {0}; i < 120; i++){
cin >> input;
/* The for-loop will begin after the prompt. Input is before the if-statement in case
-999 is inputted - it will not be counted and will not be part of the array. */
if(input != -999){
arrSum[i] = input;
sumAverage += arrSum[i];
count++;
cout << "Enter the next score or -999 to end input: ";
}
else if(input == -999 || count == 119){
break;
}
}
// Summary and output
/* If the count is more than one, display the average and the values below the average.
If the count is just one, only display the average. If the count is zero, display that
no scores were entered. */
if(input == -999 && count > 1){
cout << "The average of the scores is: " << setprecision(1) << fixed << sumAverage / count << ".\n";
cout << "The scores below the average were: ";
/* In this portion below, we need to determine the scores below the average.
I created a for-loop here that iterates through the array and compares it
to the average. It will output values less than the average. */
for(int i {0}; i < arrSum[i]; i++){
if(arrSum[i] < (sumAverage / count)){
cout << arrSum[i] << " ";
}
}
cout << "\n";
}
else if(count == 1){
cout << "The average of the scores is: " << setprecision(1) << fixed << sumAverage / count << ".\n";
}
else{
cout << "No scores were entered.\n";
}
return 0;
}`
C++ goes in #1013107104678162544
o my bad i js saw C and assumed
they're different languages