- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

To calculate distance light travels, we need to follow the basic formulae to calculate distance.

Distance = Speed x Time

Here, the following are the parameters −

speed = 186000; days = 365; seconds = days * 24 * 60 * 60;

Above, we calculated the time in seconds for an year −

days = 365; seconds = days * 24 * 60 * 60;

The following is the complete example to calculate distance light travels −

public class Demo { public static void main(String[] args) { int speed; long days, seconds, dist; speed = 186000; days = 365; seconds = days * 24 * 60 * 60; dist = speed * seconds; System.out.print("Light travels: "+dist + " miles"); } }

Light travels: 5865696000000 miles

- Related Questions & Answers
- C program to calculate distance between two points
- C program to calculate distance between three points in 3D
- How to calculate mahalanobis distance in R?
- Java program to calculate mode in Java
- Java program to calculate student grades
- Java program to calculate the percentage
- Java Program to calculate Compound Interest
- Calculate distance and duration between two places using google distance matrix API in Python?
- Java program to calculate mean of given numbers
- Java program to calculate Body Mass Index (BMI)
- Java Program to calculate area of a Tetrahedron
- Java program to calculate the average of numbers in Java
- Light Transmission
- Java program to calculate the power of a number
- Java program to calculate the product of two numbers

Advertisements