Forums: » Register « |  Free Tools |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support |

New Free Tools on Dev Shed!

#1
January 30th, 2013, 12:42 PM
 jakenbr
Registered User

Join Date: Jan 2013
Posts: 2
Time spent in forums: 48 m 36 sec
Reputation Power: 0

Write a program that takes 10 floating-point numbers listed most often. The program displays the average of the numbers followed by all of the numbers that are greater than the average. As part of your design, write a method that takes an array of doubles as a parameter and returns the average of the data in the array. Please use methods to do each task. Pass your arrays to the method to complete each task.

If someone could please help me with this and post the code I would very much appreciate it. Thank you!

#2
January 30th, 2013, 01:55 PM
 Jacques1
You have been warned

Join Date: Jul 2012
Posts: 3,106
Time spent in forums: 2 Months 3 Weeks 4 Days 13 h 46 m 13 sec
Reputation Power: 1063
Hi,

Quote:
 Originally Posted by jakenbr ... and post the code

Nope, this is not a homework service (no idea why so many people believe that).

// Yeah, and cross-posting won't help. Looks like you actually have to start thinking for yourself.

Last edited by Jacques1 : January 30th, 2013 at 02:07 PM.

#3
January 30th, 2013, 10:53 PM
 jakenbr
Registered User

Join Date: Jan 2013
Posts: 2
Time spent in forums: 48 m 36 sec
Reputation Power: 0
Ok how is this

#include<iostream>
using namespace std;
double avg(int a[], int k)
{
double sum = 0;
for(int i=0; i<10; i++)
sum = sum + a[i];
return (sum/10.0);
}

int main()
{
double a[10];
for(int i=0; i<10; i++)
{
cin >> a[i];
}
cout << avg(a,10) << endl;
for(int i=0; i<10; i++)
{
if(a[i] > avg(a,10)
cout << a[i];
}
return 0;
}

I get multiple error: class, interface, or enum expected, how do I fix this?

#4
January 30th, 2013, 11:24 PM
 Aurum84
Contributing User

Join Date: Nov 2012
Posts: 74
Time spent in forums: 3 Days 23 h 19 m 57 sec
Reputation Power: 18
Nice try Einstein ... What do you think is wrong with it? That is C(++)..... At least copy/paste with proper googling

 Viewing: Dev Shed Forums > Programming Languages > Java Help > Homework - Help Please!