Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Kattis AboveAverage I keep getting Wrong Answer but I don't know what I'm doing wrong. #include #include // for the setprecision command https://www.simplilearn.com/tutorials/cpp-tutorial/cpp-setprecision using namespace

Kattis AboveAverage I keep getting "Wrong Answer" but I don't know what I'm doing wrong.

#include #include // for the "setprecision" command https://www.simplilearn.com/tutorials/cpp-tutorial/cpp-setprecision using namespace std;

int main(){

int c; // cases

cin >> c; for (int i=0; i < c; ++i) { int n; // number of students and their scores cin >> n; int scores [n]; // scores for each class as an array int scoreSum =0; // sum of the scores to be used for the average for (int i = 0; i < n; ++i) { // inputs scores and stores them in array, then adds them together { cin >> scores [i]; scoreSum += scores [i]; } double average = (double) scoreSum / n ; // use a double because we will need 3 decimals double aboveAverage = 0; for (i = 0 ; i < n ; ++i) { if (scores [i] > average){ aboveAverage ++ ; } } cout << fixed << setprecision(3) << (double) aboveAverage / n * 100 << "%" << endl; // must have "fixed" in order to display all 3 decimals } return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What was the Dissents point?

Answered: 1 week ago

Question

4. Explain how to use fair disciplinary practices.

Answered: 1 week ago

Question

1. Which is the most abundant gas presented in the atmosphere?

Answered: 1 week ago

Question

LO3 Define job design and identify common approaches to job design.

Answered: 1 week ago