Question

Write a public static method called ave in java to return the average of two doubles.

Write a public static method called ave in java to return the average of two doubles.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;

public class Main {

public static double ave(double a, double b)

{

return ((a+b)/2);

}

public static void main(String[] args) {

double num1,num2,num3;

Scanner sc=new Scanner(System.in);

System.out.print("Enter first number :");

num1=sc.nextDouble();

System.out.print("Enter second number :");

num2=sc.nextDouble();

num3=ave(num1,num2);

System.out.println("Average of two numbers is :"+num3);

  

}

}

If you have any questions comment down and please upvote thanks...

Add a comment
Know the answer?
Add Answer to:
Write a public static method called ave in java to return the average of two doubles.
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT