Java Program for focal length of a spherical mirror
Focal length is the distance between the center of the mirror to the principal foci. In order to determine the focal length of a spherical mirror we should know the radius of curvature of that mirror. The distance from the vertex to the center of curvature is called the radius of curvature. The focal length is half the radius of curvature. Formula :
F = ( R / 2 ) for concave mirror
F = - ( R / 2 ) for convex mirror
Examples :
For a convex mirror
Input : R = 30
Output : F = 15
For a convex mirror
Input : R = 25
Output : F = - 12.5
Java
import java.util.*;
import java.lang.*;
public class GfG{
public static float focal_length_concave( float R)
{
return R / 2 ;
}
public static float focal_length_convex( float R)
{
return - ( R / 2 ) ;
}
public static void main(String argc[])
{
float R = 30 ;
System.out.print("Focal length of" +
"spherical concave"+
"mirror is : "+
focal_length_concave(R) +
" units\n");
System.out.println("Focal length of"+
"spherical convex"+
"mirror is : "+
focal_length_convex(R) +
" units");
}
}
|
Output:
Focal length ofspherical concavemirror is : 15.0 units
Focal length ofspherical convexmirror is : -15.0 units
Time Complexity: O(1)
Auxiliary Space: O(1)
Please refer complete article on Program to determine focal length of a spherical mirror for more details!
Last Updated :
23 Dec, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...