Length of the Diagonal of the Octagon | Java Program to find the diagonal of the octagon ; Function to find the diagonal of the octagon ; side cannot be negative ; diagonal of the octagon ; Driver code
import java . util . * ; class solution { static double octadiagonal ( double a ) { if ( a < 0 ) return - 1 ; return a * Math . sqrt ( 4 + ( 2 * Math . sqrt ( 2 ) ) ) ; } public static void main ( String args [ ] ) { double a = 4 ; System . out . println ( octadiagonal ( a ) ) ; } }