The distance traveled by light in a year is equal to 946 tim

The distance traveled by light in a year is equal to 9.46 times 10^12 km. Make light years-feet conversion table for light-year values from 1 to 5, with 0.1 increments. Since the length of conversion might exceed the presentable limit, formal your results to 2 decimal places by using scientific notation. Use the disp function in MATIAB to display the table title and column headers; use the fprintf function to represent the conversion data.

Solution

% matlab code light year to feet conversion table

disp(\"Light year\\tFeet\ \");
light_year = 1;
while light_year <= 5
feet = light_year*9.46*(10^12)*3280.84;
fprintf(\"%0.2f\\t\\t%0.2f\ \",light_year,feet);
light_year = light_year + 0.1;
end

%{
output:

Light year Feet   

1.00 31036746400000000.00
1.10 34140421040000008.00
1.20 37244095680000008.00
1.30 40347770320000016.00
1.40 43451444960000024.00
1.50 46555119600000016.00
1.60 49658794240000024.00
1.70 52762468880000024.00
1.80 55866143520000032.00
1.90 58969818160000040.00
2.00 62073492800000032.00
2.10 65177167440000040.00
2.20 68280842080000040.00
2.30 71384516720000040.00
2.40 74488191360000048.00
2.50 77591866000000048.00
2.60 80695540640000048.00
2.70 83799215280000048.00
2.80 86902889920000048.00
2.90 90006564560000064.00
3.00 93110239200000064.00
3.10 96213913840000080.00
3.20 99317588480000064.00
3.30 102421263120000064.00
3.40 105524937760000080.00
3.50 108628612400000064.00
3.60 111732287040000096.00
3.70 114835961680000080.00
3.80 117939636320000112.00
3.90 121043310960000080.00
4.00 124146985600000112.00
4.10 127250660240000080.00
4.20 130354334880000080.00
4.30 133458009520000064.00
4.40 136561684160000064.00
4.50 139665358800000064.00
4.60 142769033440000064.00
4.70 145872708080000000.00
4.80 148976382720000000.00
4.90 152080057360000000.00
5.00 155183732000000000.00

%}

 The distance traveled by light in a year is equal to 9.46 times 10^12 km. Make light years-feet conversion table for light-year values from 1 to 5, with 0.1 in
 The distance traveled by light in a year is equal to 9.46 times 10^12 km. Make light years-feet conversion table for light-year values from 1 to 5, with 0.1 in

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site