Questions tagged as 'else'

4
answers

IF, ELSE IF, ELSE or IF IF IF. When to use, what's the difference?

It's a very basic question, but it intrigues me a lot. See the code below: var bola = "redonda"; if(bola == "comestivel") return comer(); if(bola == "liquida") return beber(); if(bola == "redonda") chutar(); Now see the same with if ,...
asked by 23.11.2014 / 01:18
4
answers

What good practice when throwing exception within if?

What is the best practice in this case, to use else even though you know that if will throw an exception or not? option 1 (with else ): if (condicao){ throw new RuntimeException("Mensagem"); }else{ System.out.println("Não deu exce...
asked by 14.01.2014 / 11:28
2
answers

There is an "else while"

Is there any way for me to do this? While it's one thing to do that, then when is it another to do that? For example: var i = 0; while(i < 5){ //faça isso i++; } else { //faça aquilo } Is it possible to do this somehow?    ...
asked by 15.01.2018 / 12:15
3
answers

Omitting the else is a good idea in some cases, or not? [closed]

I ask myself this question every time I'm coding, because I always worry about leaving my code understandable to other programmers who will be looking at it - and myself, because maybe I will not remember what I did there. Would it be a good...
asked by 18.08.2015 / 21:49
2
answers

Question and answer with if and else in Java

No matter what I answer, both "Yes" and "yes" only show ELSE . Where am I going wrong? package saudacao; import java.util.*; public class Saudacao { public static void main(String[] args) { System.out.println("Ola, bom dia, v...
asked by 25.05.2014 / 02:11
2
answers

Display the largest and smallest values between two integers when they are different from each other

I can not display the lower and upper values.    Make an algorithm that reads two numbers and indicates whether they are the same or, if different, show the largest and smallest in this sequence. int V1,V2; printf("Valor 1 :"); scanf("%d"...
asked by 14.09.2018 / 14:33
2
answers

PHP parametric functions

I'm new to php and I'm creating a comparison of box sizes, and for that I'd like to put inside a function but I do not know which parameter to put inside the function's relatives. Someone could help me, Thanks. <?php include("caixa.php");...
asked by 21.05.2015 / 17:49
4
answers

JavaScript function with NaN error

Hello. I'm encountering a problem executing this formula, because the final answer is given as NaN. In a simplified way to explain the code, it works like this: there are two groups of three variables, and depending on the value you assign...
asked by 08.11.2017 / 21:54
1
answer

Error: The condition has length 1 and only the first element will be used

I am writing a code in R but it reports the following error:    In if ((BWGmax * (1 - exp (-K * (MCisimulate - Xm))))> WG) {: the   condition has length > 1 and only the first element will be used. Can you help me? BWGmax <- 30 K...
asked by 06.02.2016 / 14:45
1
answer

Javascript toggle or if / else on Adobe Edge Animate

I use Adobe Edge Animate for simple animations at work. I could not make one of them work and I played a trick. Now I want to know how to do it right. I have a button. When clicked, it should give play on the timeline from start to finish. If...
asked by 06.10.2015 / 00:57