First, yes I have researched this question. Yes, I have seen similar things, and have had no problem with that, but this is an added twist and I'm a bit confused. So this is what I'm trying to do:     For each iteration of the loop, toss all coins. If a coin comes up   heads then add the value of the coin to the balance. If a coin comes   up tails then subtract the value of the coin from the balance. After   all iterations, display the balance and the number of seconds it took   to execute the loop formatted to three decimal places.   Coin.java class  import java.util.Random;   public class Coin {  private String sideUp; private Random headORtail = new Random();  public Coin() //no-arg constructor to determine what side of the coin is facing up { toss(); //calls the toss method }    public Coin(String whatSide) //parameterized constructor to set initial side of coin  { sideUp = whatSide; }    public void toss() //simulates coin toss { int num = headORtail.nextInt(2); //random number in the range of 0 - 1  if(num == 0) { sideUp = "Heads"; //0 for heads } else { sideUp = "Tails"; //1 for tails }  }    public String getSideUp() //returns value of sideUp { return sideUp; }   }   CoinDemo.java     import java.util.Scanner;  public class CoinDemo {     public static void main(String[] args) {  //uses parameterized constructor to allow the programmer to set the initial sideUp Coin penny = new Coin("Tails");  //uses no-arg constructor to create coin objects Coin nickel = new Coin();  Coin dime = new Coin();   Coin quarter = new Coin(); Coin half = new Coin(); Scanner keyboard = new Scanner(System.in); //Creates a new scanner to allow user to enter input    System.out.println("Please enter the the number of coin flips to be performed.\nMust be greater than 0: "); int numFlips = keyboard.nextInt();  //Stores the user input into numFlips    //Validation loop checks value entered while (numFlips &lt;= 0) { System.out.println("\n\t~~~ERROR~~~"); System.out.println("The number entered must be greater than 0, please try again."); System.out.println("\t~~~~~~~~~~~\n");     System.out.println("Please enter the the number of coin flips to be performed. Must be greater than 0: ");     numFlips = keyboard.nextInt(); //stores the user input into numFlips }    long totalTime = System.currentTimeMillis(); //Once valid number is entered start the timer  double totalCoin;    for (int i = 0; i &lt; numFlips; i++) //for loop to increment until equal to user entered numFlips {      //calls the Coin object's toss method and stores result in their respective instance variables penny.toss(); nickel.toss(); dime.toss(); quarter.toss(); half.toss();    }  } }   My understanding is that after for example penny.toss(); executes in the loop it will either store the string "Heads" or "Tails" in the instance variable penny. So I tried to use   if (penny == "Heads")  { totalCoin += 0.01; }  else  { totalCoin -= 0.01; }   I'm not sure how else to go about this. I'm fairly new to programming, so please understand I'm trying to learn. That's why I'm here asking for help to understand how to do this.
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?
UK Standard Visitor visa application to sit for PLAB 1 without savings or job Looking for the name of a card-battle cartoon show Looking for a show about a group of three kids/teens who, using cards to change into monsters, fight and recover relics. I believe there are two or three other groups of three also trying to get the relics.  In the main group there are two boys and a girl. The boys were both white, one is from a farm and I don't know where the other is from. The girl was dark skinned and either black or blue hair. The three travelled around the world using a red plane.  I think they only use one monster primarily. The girl uses a monster created from gas and at one point is green. One of the boys uses a metal robot most of the time and at one point is given another better version of that card to use. I believe the episode for this was called something like green with envy.  All I'm getting from the internet is that it may be Chaotic, but that isn't the right show.  I also believe the girl's name was Mai and one of the boys were Ky, but I may be wrong. Isn't finding the inverse of $a$, that is, $a'$ in $aa'\equiv1\pmod{m}$ equivalent to solving the diophantine equation $aa'-mb=1$, where the unknowns are $a'$ and $b$? I have seem some answers on this site (where the extended Euclidean Algorithm is mentioned mainly) as well as looked up some books but there is no mention of this. Am I going wrong somewhere or is this a correct method of finding modular inverses? Also can't we find the Bézout's coefficients by solving the corresponding diophantine equation instead of using the extended Euclidean Algorithm? Can the union axiom be weakened? Rename command not found when running a script I'm trying to to execute a script, which uses the command rename.   When I execute it, I get a message rename: command not found. Any ideas?   if [[ -z '$3' ]]; then     shopt -s dotglob     rename "$EXPRESSION" ./* else     rename "$EXPRESSION" "$3" fi I have no idea how to do this. Any help would be appreciated. The chapter I'm on is about differentiation and the mean value theorem.  Prove $a^\alpha b^{1-\alpha} \le \alpha a + (1 - \alpha)b, \; a,b &gt; 0,\; 0 &lt; \alpha &lt; 1$ Correct formula for LED current-limiting resistor? I'm trying to work out what value resistor to use in a LED circuit. The equation I'd use to do this is:  $$ R = \frac{V_{cc} - V_f}{I_f} $$  Seems logical, and makes complete sense. The answers to the question  confirm this too.  I have the following LEDs:   \$ V_f = 3.3V \$ \$ I_{f_{typ}} = 20mA \$   Using a 5V power supply:   \$ V_{cc} = 5V \$   Plugging these into the above equation gives:  $$ \begin{eqnarray} R &amp; = &amp; \frac{V_{cc} - V_f}{I_f} \\   &amp; = &amp; \frac{5V - 3.3V}{20mA} \\   &amp; = &amp; 85\Omega \end{eqnarray} $$  All good so far.  However, if I use the calculator at , that gives me 100&Omega;. If I use the ElectroDroid app on my phone, that gives me 85&Omega;.  So, I assume that the linear1 calculator is using a different method of calculating this resistor value; is there some better way of doing this? I've tried several things already,  std::stringstream m; m.empty(); m.clear();   both of which don't work. Are battery packs allowed in hand luggage? When flying, are you allowed to bring battery packs / power banks? I'd like to bring my ACC 10400mAh Power Bank on several flights. How is Starkiller Base's beam visible from Takodana in The Force Awakens? On Takodana,      the main characters and various bar patrons can see the planet Hosnian Prime being destroyed by Starkiller Base with their (respective) naked eyes. How did they see this? Is the Hosnian system close enough to see? If it's not very close and they could just see the explosion, how did the light from it reach them so quickly? "#include" a text file in a C program as a char[] L1 & L2 Regularization in Light GBM This question pertains to L1 &amp; L2 regularization parameters in Light GBM. As per official documentation:  reg_alpha (float, optional (default=0.)) – L1 regularization term on weights.  reg_lambda (float, optional (default=0.)) – L2 regularization term on weights  I have seen data scientists using both of these parameters at the same time, ideally either you use L1 or L2 not both together.   While reading about tuning LGBM parameters I cam across one such case: Kaggle official GBDT Specification and Optimization Workshop in Paris where Instructors are ML experts. And these experts have used positive values of both L1 &amp; L2 params in LGBM model. Link below (Ctrl+F 'search_spaces' to directly reach parameter grid in this long kernel)      I have seen same in XGBoost implementations.  My question is why use both at the same time in LGBM/XGBoost.  Thanks. How to avoid using sudo when working in /var/www? I want to stop having to use sudo everytime I work in /var/www. How can I do that? I simply want to put all of my sites into this directory and work with them without too much pain. I have 3 old computers lying around right now running a P2 at 800 MHz(?), Intel Mobile 1.6 GHz, AMD Athlon XP 2000+ at 1.66 GHz, and (might not use this) P4 at 2.7 GHz, all with 512 MB Ram, and am considering clustering them together for fun/knowledge. They would be running an undecided version of linux, preferably ubuntu based.   The issue is what I want to use it for: general computing and occasional video encoding. By general computing I mean day to day tasks. However I'm not sure if every program started by a single X session is going to exist on the same machine, defeating the purpose of such a system. Will programs be split up or exist on one machine?  Second, assuming this is running 100baseT ethernet (not sure if the PCI slot itself could handle Gigabit), would the speed of having a program exist over the network be an issue? It seems that the constant asking of various things in RAM would be quite slow.  And before you say "buy another computer!", that's not the point of this question. I'm asking would it be usable, not necessarily practical. And yes I know, this is going to be extreamly power consuming. I am a newbie in combinatorics and still don't have enough tools to handle this kind of problems.  Assuming I have a set of integers: $ \{1,2,3,4,\dots,n\} $  In how many ways, can I choose $k$ numbers out of those $n$, such that none of them are consecutive?  For instance, for the following set $ \{1,2,3,4,5\} $  For $ k=3 $ I have only 1 option: $\{1,3,5\}$  My purpose is first of all to understand the way you would think about this  problem, not necessarily the solution itself (I have the final answer for it).  Thanks. Show that if $f:X\to Y$ is a continuous function if and only if the graph of $f$ is a closed subset of $X\times Y$ How to send email from MySQL 5.1 Is there any problem if the last name prints first than the first name on an air ticket? Is there any problem if the last name prints first then the first name in international air ticket? Syntax error while creating DB2 Trigger What is wrong in the below trigger syntax, I am getting this error An unexpected token "INT" was found following " DECLARE NULL_ROW_ID".  Expected tokens may include:  "END-OF-STATEMENT".. SQLCODE=-104, SQLSTATE=42601, DRIVER=3.68.61  CREATE TABLE A (     A_ID INT NOT NUll,     A_CODE VARCHAR(100) NOT NULL,     PRIMARY KEY(A_ID) );  CREATE TABLE B (     B_ID INT NOT NUll,     B_CODE VARCHAR(100) NOT NULL,     A_ID INT,     PRIMARY KEY (B_ID),     FOREIGN KEY (A_ID) REFERENCES A (A_ID)  );  CREATE OR REPLACE TRIGGER B_TRIGGER AFTER UPDATE OF A_ID ON B REFERENCING NEW AS N OLD AS O FOR EACH ROW     WHEN (N.A_ID IS NULL)     BEGIN ATOMIC         DECLARE NULL_ROW_ID INT;         SET NULL_ROW_ID = (SELECT A_ID FROM A WHERE A_CODE = 'Custom Null String');         IF NULL_ROW_ID IS NULL THEN             SIGNAL SQLSTATE '70000' SET MESSAGE_TEXT = 'Custom Null String row not found.';         END IF;     SET N.A_ID = NULL_ROW_ID;     END @   It's on DB2 Express-C 10.5 Is volunteer work allowed in the US while visiting under the VWP or a B1/B2 visa? I am going to Santa Monica for 4 weeks to polish my English in July and would like to volunteer at the Planetary Society located in Pasadena.  I am a Swiss citizen and have a biometric passport. However, I don't have any special visa, as there is no visa needed for the school I am attending and using the Visa Waiver Program, I am allowed to stay up to 90 days in the US.  Am I allowed to do volunteer work during my stay?