Giving the user options I'm creating a program to solve problems that are in one-dimension kinematics. I initially started with solving for only one variable--solving for final position--but decided to play around and solve for final velocity. Now, I want to give the user an option. After they input the necessary known variables, prompt them to ask "Would you like to calculate final position or final velocity? " . Based on the user input I want to branch the calculations, however I don't know how to get that done.    This is what I have so far...      Scanner reader = new Scanner(System.in);      System.out.print("Enter time in seconds: ");     double time = reader.nextDouble();     System.out.print("Enter the initial position in meters: ");     double initialPosition = reader.nextDouble();     System.out.print("Enter intial velocity: ");     double initialVelocity = reader.nextDouble();     System.out.print("Enter acceleration: ");     double acceleration = reader.nextDouble();      System.out.println("What would you like to calculate? ");     System.out.print("Final position or final velocity?");     String userInput = reader.nextLine();      if (userInput == "final position") {         double finalPosition = ((0.5) * (acceleration * (time * time)) + (initialVelocity * time) + initialPosition);         System.out.print("The final position is: " + finalPosition);     } else {         double finalVelcoity = (initialVelocity + (acceleration * time));         System.out.print("The final velocity is: ");     }   I understand that the condition I set in the if-statement is not allowed, but what can I replace that with?
How do I compare strings in Java? 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?
C# loop - break vs. continue In a C# (feel free to answer for other languages) loop, what's the difference between break and continue as a means to leave the structure of the loop, and go to the next iteration?  Example:  foreach (DataRow row in myTable.Rows) {     if (someConditionEvalsToTrue)     {         break; //what's the difference between this and continue ?         //continue;     } } Why do positive and negative variants of the same question elicit the same answer? get the value from force:RecordData on Init handler Is there a way we can get the value from force:RecordData on init ? I am getting the onclick event of a button.  &lt;aura:handler name="init" value="{!this}" action="{!c.doInit}"/&gt;     &lt;aura:attribute name="recordId" type="String"/&gt;      &lt;aura:attribute name="showButton" type="Boolean" default="false"/&gt;     &lt;aura:attribute name="Opportunity" type="Object"/&gt;        &lt;aura:attribute name="parentOpp" type="Object"/&gt;     &lt;aura:attribute name="oppLoadError" type="String"/&gt;     &lt;force:recordData aura:id="oppRecordLoader"                       recordId="{!v.recordId}"                       fields="Id,                               Name,                               AccountId,                               Cohort_Sem__r.End_date__c,                               LeadSource,                               Staff_Referral_Detail__c,                               lead_source_detail__c"                       targetRecord="{!v.Opportunity}"                       targetFields="{!v.parentOpp}"                       targetError="{!v.oppLoadError}"                       /&gt;   JS:  doInit: function(component, event, helper) {                     var opp = component.get("v.parentOpp");                   console.log('Name Value: '+ opp.Name);     }   Error:     Action failed: c:createIWSRecord$controller$doInit [Cannot read   property 'Name' of null] quickActionHandlerHelper.js failed to create   component - forceChatter:lightningComponent "log in to" or "log into" or "login to" When writing an instruction about connecting to a computer using ssh, telnet, etc., I'm not sure what spacing to use in this familiar spoken phrase:   "Log in to host.com" "Log into host.com" "Login to host.com"   Maybe this is entirely subjective or the realm of industry jargon, but I couldn't think of anywhere else to ask.  Any insight? durbinWatsonTest() in R for non time-series data I am trying to understand whether the Durbin-Watson test is meaningful at all when applied to regression data that have no temporal order (eg. blood pressure ~ bodyMassIndex + exercise).   I would say no, as the autocorrelation should obviously vary with the order of the subjects (which is random), but I wonder whether the durbinWatsonTest in R involves a bootstrapping of the data, where order of the bootstrapping data is shuffled each time, and then perhaps an average autocorrelation is computed over the bootstrapping samples (but then again, shouldn't this average autocorrelation be zero for randomly sampled data?).  On the other hand, the value of the statistics seems to be quite stable over multiple runs of the function, so I am even more confused...  I came across it in Andy Field's book "Discovering Statistics with R", where it is used is an example with non-time series data, although in another, more recent book of the same author ("Adventures in Statistics") it does say that the test is applicable only to time series data. Is there a clever solution to Arnold's "merchant problem"? There is a problem that appears in . The problem is also quoted .  You take a spoon of wine from a barrel of wine, and you put it into your cup of tea. Then you return a spoon of the (nonuniform!) mixture of tea from your cup to the barrel. Now you have some foreign substance (wine) in the cup and some foreign substance (tea) in the barrel. Which is larger: the quantity of wine in the cup or the quantity of tea in the barrel at the end of your manipulations?  Here's my solution: The key is to consider the proportions of wine and tea in the second spoonful (that is, the spoonful of the nonuniform mixture that is transported from the cup to the barrel). Let $s$ be the volume of a spoonful and $c$ be the volume of a cup. The quantity of wine in this second spoonful is $\frac{s}{s+c}\cdot s$ and the quantity of tea in this spoonful is $\frac{c}{s+c}\cdot s$. Then the quantity of wine left in the cup is $$s-\frac{s^2}{s+c}=\frac{sc}{s+c}$$ and the quantity of tea in the barrel now is also $\frac{cs}{s+c}.$ So the quantities that we are asked to compare are the same. However, Arnol'd also says  Children five to six years old like them very much and are able to solve them, but they may be too difficult for university graduates, who are spoiled by formal mathematical training.  Given the simple nature of the solution, I'm going to guess that there is a trick to it. How would a six year old solve this problem? My university education is interfering with my thinking. What are my best options for a tripod for up to $100? I'm looking to buy a tripod + head (for my Canon 40D), but am not sure if I want to spend more than $100 on it.  So can you suggest options for best tripods for $100 or less? Or, is it important to spend more than that on a tripod?  Extra props for options which might be available in India. Compactness of $\operatorname{Spec}(A)$ In an exercise in Atiyah-Macdonald it asks to prove that the prime spectrum $\operatorname{Spec}(A)$ of a commutative ring $A$ as a topological space $X$ (with the Zariski Topology) is compact.   Now because the basic open sets $X_f = \{\mathfrak{p} \in \operatorname{Spec} (A) : \{f\} \not\subseteq \mathfrak{p} \}$ form a basis for the Zariski Topology it suffices to consider the case when   $$X = \bigcup_{i \in I} X_{f_i}$$   where $I$ is some index set. Then taking the complement on both sides we get that   $$\emptyset = \bigcap_{i \in I} X_{f_i}^c$$  so there is no prime ideal $\mathfrak{p}$ of $A$ such that all the $f_i$'s are in $\mathfrak{p}$. Now from here I am able to show that the ideal generated by the $f_i$'s is the whole ring as follows. Since there is no prime ideal $\mathfrak{p}$ such that all the $f_i \in \mathfrak{p}$, it is clear that there is no $\mathfrak{p}$ such that $(f_i) \subseteq \mathfrak{p}$ for all $i \in I.$ Taking a sum over all the $i$ then gives $$\sum_{i \in I} (f_i) = (1).$$  Now here's the problem:          How do I show from here that there is an equation of the form $1 = \sum_{i \in J} f_ig_i,$ where $g_i \in A$ and $J$ some finite subset of $I$?       This part has been giving me a headache. I am not sure if the finiteness bit has to do with algebra, topology or the fact that we are dealing with prime ideals.  This is not a homework problem but rather for self-study.  $\textbf{Edit:}$ I have posted my answer below after the discussion with Dylan and Pierre. How can momentum but not energy be conserved in an inelastic collision? Removing nodes from graphs such that one is dependent on other - ZIO $2010$, P$1$ Greetings Community! The above problem you see is a combinatorics problem I could not solve. :( This problem is from ZIO $2010$, P$1$.     Here is what I did: Observe that every graph can be divided into "sub-groups" which may help in solving. We first remove the empty set. Then the singleton set. Consider the bigger but smaller than the sub-parts example:    The singleton sets are $\{4,5,6\}$ which are at the least position in the graph.   The dual sets are $\{2,4\}, \{3,5\}, \{3,6\}$, the bottom - two portions in the graph. The triplet sets are $\{2,4,5\}, \{4,5,6\}$ which we may manually count but for the bigger graphs in the sub-part, this may prove to be difficult and this is where I am stuck.   Any help would be appreciated. Thanks. How is acceleration measured if there is change only in the direction of velocity & not magnitude? The formal definition of acceleration is      It is the measure of how fast the velocity changes with respect to time.   Now, when the magnitude of velocity changes, acceleration $$\vec{a} = \frac{d \vec{v}}{dt}$$ and its unit is $m.s^{-2}$ .  But what about the case where the velocity only changes its direction keeping its magnitude constant? The definition can then be      Acceleration is the measure of how fast the velocity changes its direction with respect to time.   But how can I calculate the acceleration then?? What should be the unit then??? Please help. Regular Expression to match valid dates Is every Lie subgroup of $SU(2)$ closed? Windows Unable to Delete ._. File I currently have a file on the root of my external hard drive simply named ._., which I am guessing was added to my hard drive after using it on my MacBook a while ago.  I'm trying to delete this file on my Windows 10 machine; however Windows keeps claiming the file cannot be found.    I also tried deleting the file through an elevated command prompt; however the same message is returned.    Is there any way I can delete this file from my hard drive through Windows? Plot an elliptic curve in Latex Blog showing up as mobile, won't exit What does "soft" in "soft symmetry breaking" mean? How is Dru-Zod/General Zod still alive after this character died? Cycles settings missing This particular blend file is messed up. I'm not sure what I did or pressed. If I open a new blend file everything works fine but in this one the materials tab is missing and the render properties is also missing some things. I don't want to start over my project. I have tried a day and a half to figure this out. Evaluate these infinite products $\prod_{n\geq 2}(1-\frac{1}{n^3})$ and $\prod_{n\geq 1}(1+\frac{1}{n^3})$ What is   $\prod\limits_{n\geq 2}(1-\frac{1}{n^3})=?$ $\prod\limits_{n\geq 1}(1+\frac{1}{n^3})=?$   I am sure about their convergence. But don't know about exact values. Know some bounds as well. For example first one is in interval (2/3,1) and second one is in (2,3).