Write a program to compute the distance of light travels.

0
/* Write a program to compute the distance of light travels. */

class Light
{
    public static void main(String args[]){
        int lightspeed;
        long days;
        long seconds;
        long distance;
        lightspeed=186000;
        days=1000;
        seconds=days*24*60*60;
        distance=lightspeed*seconds;
        System.out.println("Lightspeed:"+lightspeed);
        System.out.println("Number of seconds:"+seconds);
        System.out.println("Total distance:"+distance);
        }
    }


/*
Output:

E:>javac Light.java
E:>java Light

Lightspeed:186000
Number of seconds:86400000
Total distance:16070400000000

*/

About the author

Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus. Aenean fermentum, eget tincidunt.

0 comments:

Recent Posts