Questions tagged as 'switch'

1
answer

How to select a switch / case statement with each click on the button

I would like to make a list of A-Z . One detail, is based on breaking / dividing this list (gem) alphabet into parts: Although my difficulty is in, after being clicked on the button, the same bring the list like this: First click...
asked by 14.04.2016 / 02:38
3
answers

Use an operator on a switch case

If I do, good wheel: #include <stdio.h> int op1; int main(){ scanf("%d", &op1); switch(op1) { case 1: puts("Hello World"); } } I wanted to make when entering a special character, for example, +, -, / (etc), shows m...
asked by 22.01.2016 / 11:30
0
answers

Why does not my switch generate the correct results? [closed]

I'm using a condition and a switch to determine some values for some variables, but I'm not getting the expected results. When the <a href="index.php?post=myFile"></a> link is clicked, I expect to run the first case on the...
asked by 02.09.2018 / 17:31
1
answer

Optimize Java code

Well, I'm creating an alarm in android and I wanted to know if you inves to make a switch for each editText if it was a way to check all in one switch, I tried with a for and I was incremented, but without success, here this is my code, I hope y...
asked by 05.11.2017 / 00:21
3
answers

Doubt with switch in JavaScript

I'm doing a JavaScript course, and I need to do an exercise with the statement " Write a function that given a total of years of study returns how experienced the user is." My code: function experiencia(anos) { switch (anos) { c...
asked by 21.07.2018 / 13:29
2
answers

Switch only enters the "default"

When I read a number, converting it to Int32 , my switch simply understands that it is a default and makes the code described there. static void Main(string[] args) { Jogador j = new Jogador(); //instancia que r...
asked by 19.02.2018 / 14:44
2
answers

Change elseif code to switch case

I'm having trouble changing a code I made in else if to switch case . I'm not getting the code to work, it gets values and operation by $_GET and does the selected operation: I leave the code here: if((!is_numeric...
asked by 07.07.2016 / 15:16
3
answers

How to insert a new value into an array without duplicating through the switch case? [closed]

One of my attempts so far has been: array = [1, 2, 4, 5]; definir = function() { switch (array) { case (array > 1): array.push(1); break; case (array > 2): array.pu...
asked by 11.02.2017 / 15:34
1
answer

Check if an element exists with switch

Hello, how do I do a check and check if a given element exists using switch?  To be more specific, I'm trying to use this code: var forumversion = function() { invision = jQuery('#ipbwrapper').length ? "invision" : "error"; phpbb2 =...
asked by 18.04.2014 / 00:08
1
answer

is there any alternative to a giant conditional without being a switch case?

$metodo = array( "1"=> fazMetodo1(), //retorna algum valor "2"=> fazMetodo2(), //retorna algum valor "3"=> fazMetodo3() //retorna algum valor //... assim vai ); $inputId = "2"; if (array_...
asked by 11.03.2016 / 16:28