Computer Science, asked by neelamala2, 1 year ago

Input: Two floating point numbers.
Output: Average of those numbers.
Test Case 1
5.0 6.0
5.500000

Answers

Answered by Aquib7089
0
Let numbers be x and y
then
float Av = x + y /2
Answered by franktheruler
0

Answer:

import java . util. * ;

class java

{

 float n1, n2, avg ;  

scanner sc = new scanner ( system . in )

  system . out . println ( enter the first number ) ;

  n1 = nextFloat ( ); // according to the question input will be 5.0

  system . out . println ( enter the Second number );

  n2 = nextFloat ( ); // according to the question input will be 6.0

public float average ( ) // Display method  

{  

  system . out . println ( Average of two numbers are ) ;

  float avg = ( n1 +n2 ) / 2 ;

  return ( avg ) ;

}

// Main method

public static void main ( string args [] )

{    

 // creating object of java class

java obj = new java ( );

obj . display ( ) ; // here we are calling the display function

}

}

Similar questions