Question: Need help fixing my C++ program, the mean is wrong.... it needs to say The median of (3, 9, 5) is 5. The mean of

Need help fixing my C++ program, the mean is wrong.... it needs to say

The median of (3, 9, 5) is 5. The mean of (4, 5, 8, 20, 25) is 12.40

What I have

Need help fixing my C++ program, the mean is wrong.... it needs

to say The median of (3, 9, 5) is 5. The meanof (4, 5, 8, 20, 25) is 12.40 What I have 3

3 9 5 4 5 8 20 25 -1 The median of (3, 9, 5) is 5. The mean of (4, 5, 8, 20, 25) is 14.00. '1 #include 2 using namespace std; 4. int main() { '6 int count = 0; '7 int total = 0; 8 int x, y, z, a, median; double avg; 10 11 scanf("%i%i%i", ex, &y, &z); //scan for the first three integers 12 if((y > x && x > z)||(z > x && X > y)) 13 14 15 16 median = x; 17 else if((x > y && y > Z)||(z > y && y > x)) 18 - 19 median = y; 20 21 else 22 23 median = z; 24 median = z; 25 26 27 printf("The median of (%i, %i, %i) is %i. ", x, y, z, median); scanf("%i",&a); 28 printf("The mean of %i", a); 29_scanf("%i", &a); 30 31 while(a! =-1) // Creating the Mean 32-{ 33 total = total + a; count = count + 1; printf(", %i", a);//Print rest of integers scanf("%i", &a); 34 36 37 39 avg = total/count; 40 41 printf(") is %0.21f. ", avg); 42 43 } 44

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!