Figured it out. Thanks guys. I know its not a perfect answer but, I'm new to java.   package Dr._Coles_Practice_Problems;  import java.util.Scanner;  public class GpaCalc {  public static void main(String[] args) {     // Needed variables       double credits = 0.0;      double totalcredits = 0.0;      double grade = 0.0;      double qualitypoints = 0;      int classes;      String lettergrade;      Scanner input = new Scanner(System.in);      System.out.println("Enter the amount of classes for this semester");      classes = input.nextInt();      while (classes &gt; 0) {      System.out.println("Enter the amount of credits for this class");      credits = input.nextDouble();      System.out.println("Enter the grade achieved for this class");      lettergrade = input.next();          if (lettergrade.equalsIgnoreCase("a")) {              grade += 4.00;          }          if (lettergrade.equalsIgnoreCase("a-")) {              grade += 3.67;          }          if (lettergrade.equalsIgnoreCase("b+")) {              grade += 3.33;          }          if (lettergrade.equalsIgnoreCase("b")) {              grade += 3.00;          }          if (lettergrade.equalsIgnoreCase("b-")) {              grade += 2.67;          }          if (lettergrade.equalsIgnoreCase("c+")) {              grade += 2.33;          }          if (lettergrade.equalsIgnoreCase("c")) {              grade += 2.00;          }          if (lettergrade.equalsIgnoreCase("c-")) {              grade += 1.67;          }          if (lettergrade.equalsIgnoreCase("d+")) {              grade += 1.33;          }          if (lettergrade.equalsIgnoreCase("d")) {              grade += 1.00;          }          if (lettergrade.equalsIgnoreCase("f")) {              grade += 0.00;          }          classes--;          totalcredits += credits;        }             qualitypoints = grade * credits;         // GPA is calculated via total credits / total quality points     //of which are calculated by multiplying the credit(s) * the quality point value       System.out.println("Your total credit(s)are: " + totalcredits);      System.out.println("Your total quality points are: " + qualitypoints);      System.out.println("Your GPA is: " + (qualitypoints / totalcredits)); }   }  /*   Bloomsburg University's grading scale  A = 4.00 Superior Attainment  A- = 3.67  B+ = 3.33  B = 3.00 Above Average Attainment  B- = 2.67  C+ = 2.33  C = 2.00 Average Attainment  C- = 1.67  D+=1.33  D = 1.00 Minimum Attainment  F = 0.00 Failure  */
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?
NSDictionary with ordered keys I have an NSDictionary (stored in a plist) that I'm basically using as an associative array (strings as keys and values).  I want to use the array of keys as part of my application, but I'd like them to be in a specific order (not really an order that I can write an algorithm to sort them into).  I could always store a separate array of the keys, but that seems kind of kludgey because I'd always have to update the keys of the dictionary as well as the values of the array, and make sure they always correspond.  Currently I just use [myDictionary allKeys], but obviously this returns them in an arbitrary, non-guaranteed order.  Is there a data structure in Objective-C that I'm missing?  Does anyone have any suggestions on how to more elegantly do this? How could I execute a script in Shell when a shortcut key is pressed.   Essentially what I need is when a shortcut key is pressed the script should read from a file and display that content in the terminal. What is the difference between the dashed and solid attack bars? I was flipping through my Pokemon list to see which kind of attacks they had, and I notice there was a small different between the attacks. Some attacks contained a dashed blue bar where as others contained a solid blue bar.   What is the difference and significance between the two? I didn't like the skill I chosen for the first follower I found. Is it possible to respec his skill later on? I am using \tableofcontents to create TOC in my document. however it is appearing as shown in the image. As the numbers increase the gap between the number and text is reducing.   Thanks for your help Aku How to get a file's Media Type (MIME type)? How do you get a Media Type (MIME type) from a file using Java?  So far I've tried JMimeMagic &amp; Mime-Util. The first gave me memory exceptions, the second doesn't close its streams properly. How would you probe the file to determine its actual type (not merely based on the extension)? Archimedes' principle for two liquid layers Problem: I have a cylindrical vessel of height $H$ and radius $R$. There are two liquid layers in the vessel. The first has density $D_1$ and height $h_1$, the second has density $D_2$ and height $h_2$. The second liquid is floating on the first liquid (thus $D_2 &lt; D_1$) and they are both entirely within the vessel ($h_1+h_2 \le H$). Now I have a cube of density $D$ and edge length $n$. The cube fits into the vessel ($n \le \sqrt2R$) but it might not be completely inside it ($n&gt;H$ is possible). I place it into the vessel such that one side is horizontal (the cube is not lopsided). Some liquid might overflow as a result. How do I use Archimedes' principle to calculate the topmost liquid level after placing the cube? I can ignore damping and other physical effects. EDIT: Note that the only values I know are $H, R, D_1, h_1, D_2, h_2, n$ and their abovementioned constraints.  My workings: I tried using the formula directly, where $\text{weight of cube}=\text{weight of displaced liquid}$. I first get $Dn^3=D_2n^2s_2$ where $s_2$ is the height submerged in the second liquid. If $s_2 \le h_2$ then the cube is only submerged in the second liquid. So the answer is $\min(H, h_1+h_2+{n^2s_2\over\pi R^2})$, accounting for overflows. This case is simple. But if $s_2&gt;h_2$ then the cube can be submerged in the first liquid too. I thought of subtracting the weight of the second liquid displaced to obtain the height submerged in first liquid, but realize that I don't know that. The weight displaced depends on the final liquid height, which can be affected by overflows, whether the cube fits totally within the two liquids, etc. In fact, it can be the case that after the liquid level rises, the cube now displaces more of the second liquid, causing it to not be submerged in the first (is that even possible?) It seems very messy and I have no idea how to start. :( Does anyone have a nice solution to this problem? If $f$ is continuous and $f'(x)\ge 0$, outside of a countable set, then $f$ is increasing Can comments be used in JSON? How to back up my entire system? If I want to make a backup of my entire OS (including but not just my home directory), how do I go about this?    Is it as simple as backing up everything in / and then when if I suffer a crash, just copying the files back over? Will this cover grub, and how do I actually do this when the system is inoperable? The question is pretty straight forward. I can get the exit code of the previous command by using $?. But what exactly is it?  I don't think it is a variable, because you can't have any special characters in the name of variable other than _.  foo?foo=10   will result in the error: foo?foo=10: command not found  So if it is not a variable, what is it? Are there others like it? I have a question pertaining to the concept of acceleration and it's formula - Both seem to give me different answers.  I was asked:     A train is moving at a velocity of $20\ \mathrm{m/s}$. It hits the breaks and starts slowing down at the rate of $8\ \mathrm{m/s^2}$. How long does it travel before coming to a stop?    $a=-8\ \mathrm{m/s^2}$ $u=20\ \mathrm{m/s}$ $v=0$ $s=?$ (Displacement is asked)   According to the formula of $s= \frac{(v^2-u^2)} {2a}$, answer I got was 25 meters.  BUT!  My concept of acceleration explains me this :    According to my intuition of acceleration and velocity, when  an object is said to be accelerating at $-8\ \mathrm{m/s^2}$, it means that with every passing second, it's velocity will reduce $8\ \mathrm{m/s}$. So,   At 1st second - Velocity = $20\ \mathrm{m/s}$ - It'll travel 20 meters. At 2nd second - $v = 20\ \mathrm{m/s}-8\ \mathrm{m/s}=12\ \mathrm{m/s}$ -  Train travels 12 meters At 3rd, it travels 4 meters. At 4th, it halts.   So total is 20+12+4 = 36 meters. It travels 36 meters before halt.  Where am I going wrong in my conceptual understanding, I really don't understand! If I am introducing someone to my daughter's husband's parents can I say "Hi, I'd like to you meet my ___". In-laws would not work here because they are my child's in-laws not my own. Is there a word for this relationship? How to break out of multiple loops? Given the following code (that doesn't work):  while True:     #snip: print out current state     while True:         ok = get_input("Is this ok? (y/n)")         if ok.lower() == "y": break 2 #this doesn't work :(         if ok.lower() == "n": break     #do more processing with menus and stuff   Is there a way to make this work? Or do I have do one check to break out of the input loop, then another, more limited, check in the outside loop to break out all together if the user is satisfied? I am trying to understand the Georgi chapter of tensor methods in $SU(3)$ representations, and I don't know how to resolve the tensor product of 2 matrices in a 2 heavy quark + 2 light antiquark system. Namely:  Let the tetraquark system be:           $QQ\bar q\bar{q}$  So, those $Q$ heavy quarks interact and can be understood in the $3\bigotimes 3$ representations for $SU(3)$, and $\bar q\bar q$ can be understood as the $\bar 3\bigotimes\bar 3=3\bigoplus\bar 6$ representations for $SU(3)$.  The interaction diagram for the $Q$ heavy quarks is shown in the following scheme, which is an analogy to the Feynman Diagram where a gluon is understood to be exchanged between upper and lower arrows:  $i'\xrightarrow{(T_{a})^{i'}_{i}}i ,  {}^iQ$  $j'\xrightarrow{(T_{a})^{j'}_{j}}j ,  {}^jQ$  So, as usuall we consider the elements of $3$ representation as $u^i$, and therefore the elements of $\bar 3$ representation as $v_{j}$.  I must understand how does the following expression transform:  $(T_{a})^{i'}_{i}(T_{a})^{j'}_{j}\cdot(1/2)\cdot (w^iv^j+w^jv^i)=\Xi\cdot(1/2)\cdot(w^{i'}v^{j'}+w^{j'}v^{i'})$  In other words, how can one give the correct value of $\Xi$?  Note1: $T_a$ is understood to be the $a-ith$ generator of the associated Lie Algebra, which come from the definition of the Gell-Mann Matrices.  $(T_{a})^{i}_{j}\propto(\lambda)_{ij}$, in matrix notation.  Note2: I understand the Young Tableaux and they are not intended to be used here, so please don't try to explain this situation through the tables.   Note3: I assume this is a purely solvable mathematical problem and doesn't need a deep insight into the physical concepts...  Also requesting information about how to understand the tensor products in these cases, since I have been checking many sources but the definitions seem not clear enough. Does it just vanish into space leaving nothing behind or does it expel some material?    Also, talking more about black holes, as far as I understand the term "temperature", it is defined by the amount of kinetic energy of the particles of a body and from what I have read, there are no particles inside a black hole, I know that you can find the temperature of a black hole by analyzing its Hawking radiation but I cant really understand how the term "temperature" can be applied to a black hole. Does it mean that whatever is that it is inside a black hole has kinetic energy? Have physicist already experienced the death of any regular black hole (by regular I mean space-sized black holes not micro ones created in labs)? Also, where is the Hawking radiation form? Because if it is released by the black hole I bet it must have formed outside the event horizon, but how exactly? Continuity $\iff$ Preimage is closed whenever set is closed I'm trying to do the following:     Prove that a function $f : S\rightarrow T$ between two topological spaces is continuous iff $f^{-1}(C)$ is closed whenever $C\subset T$ is closed.   To show that the closed-set relationship implies continuity, notice that $T-C$ is open. The preimage of this open set is $f^{-1}\left(T-C\right)=S-f^{-1}(C)$, which is open by assumption ($f^{-1}(C)$ is closed). Of course, any open set $G\subset T$ can be written in the form $T-C$ by letting $C=T-G$. Thus, for every open set $G\subset T$, the preimage is open.  To show the implication in the other way, consider a closed set $C\subset T$. $T-C$ is open, so $f^{-1}(T-C)=S-f^{-1}(C)$ is open as well ($f$ is continuous), which means that $f^{-1}(C)$ is closed. How can I sanitize user input with PHP? Can a service written in .NET self-terminate? I have a service application written in C# and under certain circumstances, I would like it to terminate itself.  This would happen after the service has been running for a while, so this would not be happening in the OnStart() event.  Everything that I have read so far suggests that the only safe way to terminate a service is through the Service Control Manager.  My service runs as Local Service and does not have the rights to start or stop services, so I can't access the SCM from the service itself.  Is there another way to self-terminate while still playing by the rules of the SCM? How can I be a good reviewer? Someday, as strange as it feels to me right now, I might be asked to review an article for publication. A while ago my advisor and I were talking about this, and it hit me that I don't really know how to be a good reviewer, beyond the basics:   Respond timely to things, Make your report clear and detailed, Have actually read the paper, Etc.   Beyond this, though, I'm completely in the dark. So I'd like to ask:     What's some good advice for a first-time reviewer?   My field is math, but I'm really interested in general advice (although advice specific to math, or another field, would also be interesting and useful).    I'd like to make this question "community wiki" or analogous, but I can't seem to figure out how - if someone can do so, please do, and then I will delete this paragraph.