Pure Programmer
Blue Matrix


Cluster Map

Project: Light-Year Distance

Write a program that computes the distance light can travel in one [[Julian year]]. This is known as a [[light-year]]. Light travels at the speed of 299,792,458 m/s and a Julian year is 365.25 days long.

Output
$ rustc LightYearDistance.rs error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> LightYearDistance.rs:7:37 | 7 | static speedOfLight:f64 = 299792458.f64; | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 7 | static speedOfLight:f64 = 299792458.0f64; | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> LightYearDistance.rs:9:49 | 9 | println!("Light-Year: {} m", speedOfLight * 60.f64 * 60.f64 * 24.f64 * 365.25f64); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 9 | println!("Light-Year: {} m", speedOfLight * 60.0f64 * 60.f64 * 24.f64 * 365.25f64); | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> LightYearDistance.rs:9:58 | 9 | println!("Light-Year: {} m", speedOfLight * 60.f64 * 60.f64 * 24.f64 * 365.25f64); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 9 | println!("Light-Year: {} m", speedOfLight * 60.f64 * 60.0f64 * 24.f64 * 365.25f64); | + error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields --> LightYearDistance.rs:9:67 | 9 | println!("Light-Year: {} m", speedOfLight * 60.f64 * 60.f64 * 24.f64 * 365.25f64); | ^^^ | help: if intended to be a floating point literal, consider adding a `0` after the period | 9 | println!("Light-Year: {} m", speedOfLight * 60.f64 * 60.f64 * 24.0f64 * 365.25f64); | + error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0610`.

Solution