So the code is supposed to continually give fibonacci values for any given number until you enter "q", but for some reason instead of stopping, I get an error, anyone know why? I know that if you try to parse a string, it will cause the error but I have "if(input != "q")" to stop that so why is it still happening?  Tester class:  import java.util.Scanner; public class FibonacciTester {     public static void main(String[] args)     {         String input = "1";         System.out.println("Input a positive integer that you want to find the fibonacci number for");         System.out.println("Type 'q' to quit");         Scanner in = new Scanner(System.in);         while (input != "q"){             System.out.print("Type in the positive integer");             input = in.next();             if(input != "q"){                 int number = Integer.parseInt(input);                 FibonacciV fibonacci = new FibonacciV(number);                 number = FibonacciV.fibonacci(number);                 System.out.println("The Fibonacci number: " + number);               }         }     } }   Class  public class FibonacciV  {     FibonacciV(int x)            {     }     public static int fibonacci(int x)     {         if (x == 0)            //Base case         {             return 0;         }         else if (x == 1)       //Second base case         {             return 1;         }         else          {             return fibonacci(x-1)+ fibonacci(x-2);   // recursive call         }      } }
I've been using the == operator in my program to compare all my strings so far. However, I ran into a bug, changed one of them into .equals() instead, and it fixed the bug.  Is == bad? When should it and should it not be used? What's the difference?
One of the assumptions I make as GM is that the players should always be in the spotlight.  Sometimes the players find themselves in a situation where they watch NPCs speak to each other.  I don't like using this kind of situation, because it forces the players to watch me talk to myself and that turns them from active participants into an audience.  Usually I handle it by avoiding the situation.  I try not to write scenes that the players watch.  Instead the players speak to the NPCs one at a time.  When I do come across an exchange between NPCs I opt to summarize the conversation instead of acting it out.    I don't like this limitation though.  It gets a little contrived when all conversations in the game feature 5 PCs and 1 NPC.  Any suggestions? Either how to avoid doing it, or how to effectively role play a conversation between two (or more) NPCs that the characters may or may not be interacting with?   How do you keep clear which character is speaking? How do you make sure that the conversation feels like a real one and not like one person playing both roles? Why is complete strong induction a valid proof method and not need to explicitly proof the base cases? I've been digging through some parts of the Linux kernel, and found calls like this:  if (unlikely(fd &lt; 0)) {     /* Do something */ }   or  if (likely(!err)) {     /* Do something */ }   I've found the definition of them:  #define likely(x)       __builtin_expect((x),1) #define unlikely(x)     __builtin_expect((x),0)   I know that they are for optimization, but how do they work? And how much performance/size decrease can be expected from using them? And is it worth the hassle (and losing the portability probably) at least in bottleneck code (in userspace, of course). How can I reorder my divs using only CSS? I have seen many ways to make a USB an installer for about any Windows OS. But how can I (using grub or something like that) make it bootable to all editions on Windows XP and 7?   I have tried Googling it and researching, I've even tried to do it, But I dont understand much about GRUB or linux at all.  Please keep in mind that I am not very good with linux, so please use as many details as possible. I have a statement,     Either p or q   and I have to write it in terms of logical connectives but I don't get which logical connector should I be using? Here is what I did (I think there could have been a better way to do this)     $(p \lor q ) \land (\neg((p \Rightarrow q) \land (q \Rightarrow p)))$ Is this algebraic identity obvious? $\sum_{i=1}^n \prod_{j\neq i} {\lambda_j\over \lambda_j-\lambda_i}=1$ If $\lambda_1,\dots,\lambda_n$ are distinct positive real numbers, then  $$\sum_{i=1}^n \prod_{j\neq i} {\lambda_j\over \lambda_j-\lambda_i}=1.$$ This identity follows from a probability calculation that you can find at the  top of page 311 in the 10th edition of Introduction to Probability Models by Sheldon Ross.   Is there a slick or obvious explanation for this identity?   This  question is sort of similar to ; clearly algebra is not my strong suit! How can the median number of sexual partners be 6.1 and 3.6? Median number of female sexual partners in lifetime, for men 25-44 years of age, 2006-2008: 6.1  Wouldn't it only be able to be x.5 or x.0? This is what I would like to do:  morekeywords={SENÃO, ENTÃO, FAÇA, ATÉ, ENQUANTO, PARA, SE, DECLARA, DECLARE, E, OU, FIM_ENQUANTO, FIM_PARA}   I'm defining a new language, and I would like to use natural language words as keywords.  The problem is with keywords: SENÃO, ENTÃO, FAÇA, ATÉ.  I have solved the first problem, in showing special chars with:   The alsoletter here, doesn't work for me, I got an error when using it: alsoletter={Ç,É,Ã}.  test.tex  \documentclass{article}  \usepackage[brazilian]{babel} \usepackage[T1]{fontenc}  \usepackage[utf8]{inputenc} \usepackage{listingsutf8}  \usepackage{listings}  \lstset{%         inputencoding=utf8,         extendedchars=true,         literate=%         {é}{{\'{e}}}1         {è}{{\`{e}}}1         {ê}{{\^{e}}}1         {ë}{{\¨{e}}}1         {É}{{\'{E}}}1         {Ê}{{\^{E}}}1         {û}{{\^{u}}}1         {ù}{{\`{u}}}1         {â}{{\^{a}}}1         {à}{{\`{a}}}1         {á}{{\'{a}}}1         {ã}{{\~{a}}}1         {Á}{{\'{A}}}1         {Â}{{\^{A}}}1         {Ã}{{\~{A}}}1         {ç}{{\c{c}}}1         {Ç}{{\c{C}}}1         {õ}{{\~{o}}}1         {ó}{{\'{o}}}1         {ô}{{\^{o}}}1         {Õ}{{\~{O}}}1         {Ó}{{\'{O}}}1         {Ô}{{\^{O}}}1         {î}{{\^{i}}}1         {Î}{{\^{I}}}1         {í}{{\'{i}}}1         {Í}{{\~{Í}}}1 }  \lstdefinelanguage{pseudo} { extendedchars=true, alsoletter={_}, morekeywords={ENQUANTO,PARA,SE,SEN\~{A}O,ENTÃO,ATÉ,FA\c{C}A,DECLARA,DECLARE,E,OU,FIM_ENQUANTO,FIM_PARA,FAÇA}, ndkeywords={NUMERO,TEXTO,LEIA,ESCREVA}, sensitive=true, morecomment=[l]{//}, morecomment=[s]{/*}{*/}, morestring=[b]" }  \begin{document} \lstinputlisting[language=pseudo]{foo.pseudo} \end{document}   foo.pseudo  ENQUANTO nota != -1 FAÇA // Comment example  LEIA nota  SE nota &gt;= 7 ENTÃO    ESCREVA "Aprovado"  SENÃO    ESCREVA "Reprovado"    TEST "Algo mais" /* mais  comentário */  FIM_ENQUANTO    I have seen: How to smooth shade an object while retaining hard edges? I frequently come to the problem of having a mesh with parts I would like to render smooth and "hard" edges connecting them.   How can I set the mesh to show the sharp edges but render everything else smooth?  In the example I would like the sides of the individual cylinders render smooth but the intersection between bottom and top to be sharp/flat How can I use the compositor on the result of the sequencer? I recently ran a renderfarm on a file with some compositing setup, but I forgot to set the composite output back to the Composite node instead of the Viewer I was temporarily using. Since the node setup didn't require anything besides the image data (i.e., no Z-buffer, object IDs, etc.) I figured that I could just run the compositor on each frame individually. However, this proved to be somewhwat difficult.  It seems that the sequencer is run after the compositor (despite their non-exclusivity in the Post Processing panel), so my idea to use an image strip in the sequencer for all the images that I already rendered didn't work&mdash;the render just copied the images into a new directory.  The Movie Clip node doesn't seem to accept an image strip as input, either, so that was not an option.  What I ended up doing was sequencing the animation to a movie file, then piping that into the Movie Clip node in the compositor. However, this required extra time, extra storage, and it rendered the default scene every frame before compositing, only to ignore the result.  Is there a way to use Blender's compositor either directly on an image sequence, or in conjunction with the video sequencer? An idiom for deriving pleasure from another's suffering I believe it is what the Germans call "". English itself has no such equivalent word. (Although it has been adopted as a .)  Does an idiom exist that describes it? Converting from shapefile or raster formats to LAS? I have data in an Excel file that I want to join with a shapefile in my project. The Excel file contains values like volumes. The Excel file and the shapefile I want to join it with both contain the same property names.  The problem is, when I join the two, I get too many decimals in the attribute table. I get six, but I only want it to be one.  I tested to change the format of the cells to one decimal, and then I saved the file as *csv. But, somehow I seem to loose data in the process? It should be 42 rows that contains data in the column i am working with, but I end up with only like 10?  Another thing is that my property names contains the letters Å. Ä and Ö, perhaps this complicates things?  I read the question , but it doesn't mention the problem with the data loss.  My question was tagged with , but I didn't write what version I'm using. I use QGIS 2.2.0. Would it help to upgrade to the latest version? Number of permutations of $n$ elements where no number $i$ is in position $i$ I am trying to figure out how many permutations exist in a set where none of the numbers equal their own position in the set; for example, $3,1,5,2,4$ is an acceptable permutation where $3,1,2,4,5$ is not because 5 is in position 5.  I know that the number of total permutations is $n!$. Is there a formula for how many are acceptable given the case that no position holds its own number? I need to knock out a quick animation in C#/Windows Forms for a Halloween display.  Just some 2D shapes moving about on a solid background.  Since this is just a quick one-off project I really don't want to install and learn an entire new set of tools for this.  (DirectX dev kits, Silverlight, Flash, etc..)  I also have to install this on multiple computers so anything beyond the basic .Net framework (2.0) would be a pain in the arse.  For tools I've got VS2k8, 25 years of development experience, a wheelbarrow, holocaust cloak, and about 2 days to knock this out.  I haven't done animation since using assembler on my Atari 130XE (hooray for page flipping and player/missile graphics!)  Advice?  Here's some of the things I'd like to know:   I can draw on any empty widget (like a panel) by fiddling with it's OnPaint handler, right?  That's how I'd draw a custom widget.  Is there a better technique than this? Is there a page-flipping technique for this kind of thing in Windows Forms?  I'm not looking for a high frame rate, just as little flicker/drawing as necessary.   Thanks.  Post Mortem Edit ... "a couple of coding days later"  Well, the project is done.  The links below came in handy although a couple of them were 404.  (I wish SO would allow more than one reply to be marked "correct").  The biggest problem I had to overcome was flickering, and a persistent bug when I tried to draw on the form directly.   Using the OnPaint event for the Form: bad idea.  I never got that to work; lots of mysterious errors (stack overflows, or ArgumentNullExceptions).  I wound up using a panel sized to fill the form and that worked fine. Using the OnPaint method is slow anyway.  Somewhere online I read that building the PaintEventArgs was slow, and they weren't kidding.  Lots of flickering went away when I abandoned this.  Skip the OnPaint/Invalidate() and just paint it yourself.  Setting all of the "double buffering" options on the form still left some flicker that had to be fixed.  (And I found conflicting docs that said "set them on the control" and "set them on the form".  Well controls don't have a .SetStyle() method.)  I haven't tested without them, so they might be doing something (this is the form):      this.SetStyle(ControlStyles.UserPaint, true);     this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);     this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);    So the workhorse of the code wound up looking like (pf is the panel control):      void PaintPlayField()     {         Bitmap bufl = new Bitmap(pf.Width, pf.Height);         using (Graphics g = Graphics.FromImage(bufl))         {             g.FillRectangle(Brushes.Black, new Rectangle(0, 0, pf.Width, pf.Height));             DrawItems(g);             DrawMoreItems(g);             pf.CreateGraphics().DrawImageUnscaled(bufl, 0, 0);         }     }   And I just called PaintPlayField from the inside of my Timer loop.  No flicker at all. Let's say I have Table A: BookingsPerPerson  Person_Id    ArrivalDate    DepartureDate 123456       2012-01-01     2012-01-04 213415       2012-01-02     2012-01-07   What I need to achieve with a view is the following:  Person_Id    ArrivalDate    DepartureDate    Jan-01    Jan-02    Jan-03    Jan-04    Jan-05    Jan-06    Jan-07 123456       2012-01-01     2012-01-04       1         1         1         1 213415       2012-01-02     2012-01-07                 1         1         1         1         1         1   The system is for events, so each hotel booking could take anything between 1 to 15 days but no more than that. Any ideas would be very much appreciated. show that  $$\int_{0}^{\infty} \frac {\sin^3(x)}{x^3}dx=\frac{3\pi}{8}$$  using different ways  thanks for all Workflow for converting LaTeX into Open Office / MS Word Format I often have to write up reports based on the analysis of some data. I use R to analyse the data and export tables, figures, and text. This is then included into a LaTeX document either using input or Sweave ().  However, when I collaborate with others, I sometimes need to provide a document in Open Office / MS Word format.  Question:  Thus, assume the simplest scenario   I have a LaTeX document with text, tables, and figures I need to export this reliably into Open Office or MS Word format: this includes mathematical formulas, table formatting, and quality figures) I don't need to go back from MS Word to LaTeX   What is a reliable, efficient, and preferably free process?  Initial Thoughts:   Export to HTML,  LaTeX - LyX - ODF Use odfWeave  that deals with some specific issues associated with LaTeX to Open Office conversion    I was hoping that there is an expert out there who has worked out a good system already. Placement of question mark when terminal quote has no question mark but sentence does Possible Duplicate:          If I'm quoting something someone said and the quote does not have a question mark, but I want to end the sentence with a question mark, would it be     Are you sure she said "Spicy?"   or       Are you sure she said "Spicy"?