cd | What directory are you in? | |
What is the contents of this directory? | ||
cd / | What directory are you in? | |
What is the contents of this directory? | ||
cd ~ | What directory are you in? | |
What is the contents of this directory? | ||
cd /home/YOU | (Replace YOU with your login name) What directory are you in? | |
What is the difference between this command and the previous one? | ||
ls /home/gtowell/Public206 | What did this command do? | |
What is the difference between this and cd /home/gtowell/Public206 followed by ls | ||
cd /home/gtowell/206 | What directory are you in? | |
You should have noted that you could not cd into this directory. UNIX has a concept of "permissions". These specify whether you are allow into a directory, and weather yo can read or write a file. Generally you have permission to do anything in the directory /home/YOU and anywhere beneath that. Other places, not so much. |
public class EchoCount { public static void main(String[] args) { new EchoCount().echo(); } public EchoCount() { } public void echo() { try (BufferedReader br = new BufferedReader(new FileReader("/home/gtowell/Public206/lab01/descent.txt"));) { int lineCount=0; while (null!=br.readLine()) lineCount++; System.out.println("Lines read " + lineCount); } catch (FileNotFoundException fnf) { System.err.println("Could not open the file" + fnf); } catch (IOException ioe) { System.err.println("Reading problem" + ioe); } } }
1 1 1.0 1 2 2.0 2 3 1.5 3 5 1.6666666666666667 5 8 1.6 8 13 1.625 13 21 1.6153846153846154 21 34 1.619047619047619 34 55 1.6176470588235294 55 89 1.6181818181818182 89 144 1.6179775280898876 144 233 1.6180555555555556 233 377 1.6180257510729614 377 610 1.6180371352785146 610 987 1.618032786885246 987 1597 1.618034447821682 1597 2584 1.6180338134001253 2584 4181 1.618034055727554 4181 6765 1.6180339631667064 6765 10946 1.6180339985218033Here is the the core code for computing the fibonacci sequence. You will need to write a more code to make this useful.
int n_2=1; int n_1=1; for (int i=1; i<20; i++) { int nI = n_2 + n_1; n_1 = n_2; n_2 = nI; }When calculating the golden mean you will want to watch out for an issue with integer versus floating point division