Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Averaging Parameters Lab HELP!!

So in my Comp-Sci class I was given a worksheet to do with code on it.
code written with jGrasp by the way...

public class DemoAverage{

public static void main(String[] args){
int t1 = 90, t2=85, t3=70, t4=89, t5 = 88, t6 = 100, t7 = 65, t8=76;

System.out.println("*****Welcome to my average machine*****");
System.out.println(" Demonstrating averages
");
System.out.println("The average of " + t1+ " and " + t2 + " is "+average(t1,t2));
System.out.println("The average of " + t5+ ", "+t3 +" and " + t7 + " is "+average(t5,t3, t7));
double ave1 = average(t8,t3,t4,t1,t5);
System.out.println("The average of " + t8+ ", "+t3 +", "+t3 + ", "+t4 + " and " + t1 +
" is " +ave1);
double ave2 = average(t1,t3,t5,t7);
System.out.println("The average of " + t1+ ", "+t3 + ", "+t5 + " and " + t7 + " is " +ave2);
double ave3 = average(t2,t4,t6,t8);
System.out.println("The average of " + t2+ ", "+t4 + ", "+t6 + " and " + t8 + " is " +ave3);
averageAverages(ave1, ave2, ave3);
System.out.println("The End");
}

public static double average(int a,int b) {
return (a + b) / 2.0;
}

public static double average(int a,int b, int c) {
return (a + b + c) / 3.0;
}
public static double average(int a,int b, int c, int d) {
return (a + b + c + d) / 4.0;
}
public static double average(int a,int b, int c, int d, int e) {
return (a + b +c + d + e) / 5.0;
}
public static double average(double a,double b, double c) {
return (a + b + c) / 3.0;
}

public static void averageAverages(double a1, double a2, double a3){
double aa = average(a1, a2, a3);
System.out.println("The averages of the averages " + a1 + ", "+a2 +" and "+a3+" are " +aa);
}
}


The program averages the averages of numbers.

I struggled with these questions:

14. Add a method to your program to average 2 averages

public static void averageAverages(double a, double b)



15. Add a statement to the main method to call your new method.


16. Final List:



17. Final run:

I assume the code at 14 is what I'm supposed to put into the program, right?
I have no clue where to put it and how.
When I do it just does not work

If someone can explain to me, in plain noob english, what EXACTLY am I supposed to do.

Where did a1 a2 a3 come from and why doesn't it work with the code on question 14 that kind of stuff?

My father and I have been staying up night after night trying to figure this thing out could someone help us?

Sign In or Register to comment.