Programming Intro

Programming intro: I like space stuff so I did a little programming. This is very basic, hardcoded stuff with Java. I downloaded java JDE and hard coded a bunch of variables and output them here. I used online-java.com. I love space and thought it would be cool to understand certain basic computations about space, time and distance.

At the bottom I use more dynamic variables to compute calculations and distances.

I’d like to code at least 50 different galaxies and their distances from Earth and the Milky Way galaxy. Feel free to use https://www.online-java.com/ to start programming yourself.

You can copy the code below and paste it in online java and run the code

Programming Intro 2

Programming Intro 3


public class Main
{
public static void main(String[] args) {
System.out.println("Hello World");
String lymstring = "9,460,730,472,580,800 meters";
String lykmsstring = "9.461 trillion km";
String lyAU = "63241.077 AU";
String lyParsec = ".306601 Parsec";
int numsecsday = 0;
int numhoursday = 24;
int numminhour = 60;
int numsecsyear = 0;
int daysyear = 365;

numsecsday = numhoursday * numminhour;
    numsecsyear = numsecsday * daysyear;

    System.out.println("\r\n");

    System.out.println("1 Light years in meters " + lymstring);
    System.out.println("1 Light years in kilometers: " + lykmsstring);
    System.out.println("1 Light years in AU: " + lyAU);
    System.out.println("1 Light years in Parsec: " + lyParsec);
    System.out.println("\r\n");

    System.out.println("There are " + numsecsday + " seconds in a day");
    System.out.println("There are " + numsecsyear + " seconds in a year");

    System.out.println("\r\n");       

    double acLY = 4.25;

    System.out.println("The closest solar system to Earth is Alpha Centauri + "  + acLY + "light years away");

    int cmdLY = 25000;
    System.out.println("The closest galaxy to Earth is Canis Major dwarf 25k light years away"); 

    String galaxylong = "359 56' 39.4";
    String galaxylat = "0 2' 46.2";
    String earthlong = "179 57 39.4";
    String earthlat = "+0 2' 46.2";
    String earthdistance = "7,940 ± 420 parsecs";
    String earthdistanceLY = "25,900 ± 1,400 light years";

    System.out.println("\r\n");
    System.out.println("The galaxy coordinates long: " + galaxylong );
    System.out.println("The galaxy coordinates lat: " + galaxylat );
    System.out.println("\r\n");
    System.out.println("The earths (milky way) coordinates long: " + earthlong );
    System.out.println("The earths (milky way) coordinates lat: " + earthlat );
    System.out.println("\r\n");
    System.out.println("The earths distance: " + earthdistance );
    System.out.println("The earths distance LY " + earthdistanceLY );

}
}

used more dynamic variables in this instance

programming intro
public class Main
{
    public static void main(String[] args) {
    System.out.println("Hello World");    
long lym = 0;
long lykm = 0;
long lyAU = 0;
long lymi = 0;
long lyParsec = 0;
long lyms = 299792458;
long lykms = 300000;
long lymis = 186000;
double lyAUs = 0.00200399;
double lyParsecs = .307;
int numsecmin = 60;
int numminhour = 60;
int numhoursday = 24;
int numsecsday = 0;
int numsecsyear = 0;
int daysyear = 365;

    String lymstring = "9,460,730,472,580,800 meters";
    String lykmsstring = "9.461 trillion km";
    String lyAUstring = "63241.077 AU";
    String lyParsecstring = ".306601 Parsec";

    numsecsday = numhoursday * numminhour * numsecmin;
    numsecsyear = numsecsday * daysyear;

    lym = numsecsyear * lyms;
    lykm = numsecsyear * lykms;
    lymi = numsecsyear * lymis;
    System.out.println("\r\n");

    System.out.println("1 Light years in meters " + lym);
    System.out.println("1 Light years in kilometers: " + lykm);
    System.out.println("1 Light years in miles : " + lymi);
    System.out.println("1 Light years in AU: " + lyAUstring);
    System.out.println("1 Light years in Parsec: " + lyParsecstring);
    System.out.println("\r\n");

    System.out.println("There are " + numsecsday + " seconds in a day");
    System.out.println("There are " + numsecsyear + " seconds in a year");

    System.out.println("\r\n");       

    String centeruniverselong = "17h 45m 40.0409s";
    String centeruniverselat = " −29° 00′ 28.118″ (J2000)";
    String galaxylong = "359 56' 39.4";
    String galaxylat = "-0 2' 46.2";
    String earthlong = "179 57 39.4";
    String earthlat = "+0 2' 46.2";
    String earthdistance = "7,940 ± 420 parsecs";
    String earthdistanceLY = "25,900 ± 1,400 light years";

    System.out.println("The center of galaxy near Sagittarius A* long: " + centeruniverselong );
    System.out.println("The center of galaxy near Sagittarius A* lat: " + centeruniverselat );
    System.out.println("\r\n");
    System.out.println("The galaxy coordinates long: " + galaxylong );
    System.out.println("The galaxy coordinates lat: " + galaxylat );
    System.out.println("\r\n");
    System.out.println("The earths (milky way) coordinates long: " + earthlong );
    System.out.println("The earths (milky way) coordinates lat: " + earthlat );
    System.out.println("\r\n");
    System.out.println("The earths distance: " + earthdistance );
    System.out.println("The earths distance LY " + earthdistanceLY );
    System.out.println("\r\n");

    int acLY = (int) 4.25;
    System.out.println("The closest solar system to Earth is Alpha Centauri "  + acLY + " light years away");
    int cmdLY = 25000;
    System.out.println("The closest galaxy to Earth is Canis Major dwarf " + cmdLY + "k light years away"); 
    System.out.println("\r\n");

    System.out.println("It would take us " + (acLY * lykm) + " KM to get to nearest solar system");
    System.out.println("It would take us " + (cmdLY * lykm) + " KM to get to nearest galaxy system");
    System.out.println("\r\n");        
    System.out.println("It would take us " + (acLY * lymi) + " MI to get to nearest solar system");
    System.out.println("It would take us " + (cmdLY * lymi) + " MI to get to nearest galaxy system");


}
}

Leave a Reply

%d bloggers like this: