Most voted "switch" questions
In programming, a switch instruction is a type of selection control mechanism used to allow the value of a variable or expression to change the program execution control flow
Learn more…134 questions
Sort by count of
-
0
votes3
answers1185
viewsHow to insert a new value into an array without duplicating through the switch case?
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.push(2); break; case (array…
-
0
votes1
answer118
viewsHow do I switch a class of buttons that trigger a player to appear and hide?
I have 3 buttons in Link format with the classes: . icon-play, . icon-pause and . icon-download, I want to change the play class with pause, as well as the reverse without influencing the download…
-
0
votes1
answer383
viewsSwitch Android catching Varialvel
I have a Switch component and would like to get its status whether it’s on or off. When searching on the net the examples that I got didn’t work but one worked but it only takes the value when I…
-
0
votes1
answer499
viewsSwitch case on Submit button according to button ID
I have 7 buttons of Submit in a form. Being: Four of that: <input type="submit" id="chamado1" class="mr-abre-btn" value="Abrir chamado"> Two of this: <input type="submit" id="chamado2"…
-
0
votes1
answer238
viewsData does not persist on switch case
Write a program that registers the name, height, weight, Cpf and sex of some people. With the data registered, then locate a person through your CPF and print your IMC. When I choose the Query…
-
0
votes1
answer41
viewsProblem to enter Switch
Good afternoon, when running the program below, after typing the third note, the program ends without typing the letter needed to enter the switch. I tested with "i" getting whole number and the…
-
0
votes2
answers170
viewsSwitch only enters "default"
When I read a number, converting it to Int32, my switch simply understands that it is a default and makes the code there described. static void Main(string[] args) { Jogador j = new Jogador();…
-
0
votes0
answers39
viewsHow can I make one switch run in parallel with another?
I made this code for moving a character to a college assignment, but I wish that when I pressed the 'a', I could still walk and the ship wasn’t erased, just as I could press the 'a' several times…
-
0
votes4
answers1092
viewsDoubt 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…
-
0
votes6
answers1947
viewsUse switch to test if a value is between a range of values
I’m not able to compare the values within a switch case: function determinarGeracao(anoDeNascimento) { /* Complete a função onde voce deve comparar o * valor da variavel anoDeNascimento e atribuir…
-
0
votes1
answer97
views -
0
votes1
answer92
viewsI need to initialize the variable with the value 0, why?
import java.util.Scanner; public class Main { public static void main(String[] args) { int codigo, quantidade; double preco; Scanner sc = new Scanner(System.in); codigo = sc.nextInt(); quantidade =…
-
0
votes0
answers25
viewsHow to check the value of various Switchs in Android Studio
Hello, I’m creating a Checklist app, but Checklist has over 30 items and I’m using "Switch". When the user fills everything she will send to a database where someone else will see the items that are…
-
0
votes1
answer315
viewsHow to make a menu repeat itself until a variable option?
I am making a program in C++ that must generate three numbers and organize them according to the user’s choice, two options are provided and he must choose one, but I don’t know how to make the menu…
-
0
votes1
answer60
viewsComparing strings to switch in PHP
The point is this: A company will give a salary increase to its employees from according to the category of each employee. The increase will follow the following rule: Employees in categories A and…
-
0
votes1
answer155
viewsUse of switch case to choose a function
I would like to use the switch case to choose which function will proceed with the program. The program has 3 functions: a sum function, another multiplies and the last one is responsible for…
-
0
votes0
answers113
viewsSuggestion for Login with Access Levels php mysql
I need a hint as to how you would implement a login system via php and mysql with access levels, example: I have a database Mysql with is registered users, this in turn has several different access…
-
0
votes1
answer23
viewsHow to compare a typed Jtextfield String with a randomized Imageicon in a package?
At the level of Random in a package of Imageicon of flags of countries how to compare if it was typed right the name of the flag of the country in a Jtextfield by the user? To randomize the images…
-
0
votes1
answer112
viewsReact - Initial error in the checked Switch property (React-Switchery)
I’m using the library’s Switch component React-Switchery in the React, on a work project. I used it on several screens without any problem, but in a specific screen the following occurs: even with…
-
-1
votes2
answers273
viewsSwitch with several POST
I have a question about the Switch . I want to put several options for a Switch and currently I have so and does not work: if (isset($_POST['estado'])&& ($_POST['Distrito'])) {…
-
-1
votes1
answer243
viewsPaging with Switch
Where I choose my options: <span class="IWLABEL10CSS" id="IWLABEL7">Distrito</span> <select name="Distrito" size="1" width="180" class="COMBODISTCSS" id="COMBOFAB" tabindex="1">…
-
-1
votes1
answer412
viewsProblem with PHP paging
I’m having problems with paging, I have the main page where you can find the whole structure of my site, called main.php where there is the switch to open the files, so. MAIN PAGE.PHP switch(@…
-
-1
votes1
answer48
viewsError with switch in Swift
Guys, I’m having an error in the following code. The error is on the switch, the following error appears: expected declaration. What to do? import UIKit class ViewControllerAnalseOP1:…
-
-1
votes1
answer285
viewsProblem with switch inside the While loop
I would like a help to solve the problem I’m having with the switch inside the loop, it never finalza, stays in an eternal loop. What should I do to solve ? #include <stdio.h> #include…
-
-1
votes1
answer139
viewsJava: Problem with Substring
I created a program to translate musical notes from a site to a more readable format, it receives and analyzes every two digits of a string looking for them (as key) within a hashmap, if found, the…
-
-1
votes1
answer394
viewsError code in Switch Case
I have to do the following exercise: Make a program in Java that requests the total amount spent by the a store, print the payment options, request the desired option and prints the total amount of…
-
-1
votes2
answers390
viewsIs that a bug in the PHP SWITCH?
I’m trying to make a switch in PHP, but it returns me some very strange values. For example, if the variable $xp is equal to 0, it returns to me that the level is 20. I don’t get it '-' switch($xp){…
-
-2
votes2
answers302
viewsWhen I run the commands on Switch Case, does it end instead of going back to Menu?
int main(){ int tensao, corrente, resistencia, potencia, tempo, cargaeletrica, trabalho, i; printf("\nPara calculo de Tensao(resistencia*corrente) digite 1\n\nPara calculo de…
-
-2
votes1
answer106
viewsHelp me with this while and switch code in C?
Well I did this code in college, where it receives two integers and as the User chooses it performs an arithmetic operation with these two numbers typed. I believe my logic is correct, it compiles…
-
-3
votes5
answers2197
viewsHow to create a switch.. case with value ranges?
If a total of days is over 30 and under 60, I do something. If it’s over 60 and under 90 I do something else and so on. How do I do this case? Did the case is the best option?…
-
-3
votes1
answer62
viewsProblem with switch case inside for loop
I need help with my code with switch case inside for loop. I’m a beginner in programming and I don’t understand why the loop doesn’t run as desired. The desired would be to run the printfs before…
-
-4
votes1
answer145
viewsIF x SWITCH - Simulating
I believe that all of us always time to make some deals in conditions with few values. I made a test between the IF and the SWITCH. All content, was created to SIMULATE a more identical structure…
-
-5
votes3
answers247
viewsSwitch Result
<?php include("conectar.php"); $quantidade = 1; $pagina = (isset($_GET ['pagina'])) ? (int) $_GET['pagina'] : 1; $inicio = ($quantidade * $pagina) - $quantidade; $where =…
-
-5
votes2
answers151
viewsswitch does not show the expected result
What’s wrong? It was supposed to appear "no value", but when it starts with zero appears "very high value" in the message. <?php $num = 0; switch ($num){ case($num>100); echo'valor muito…