All Questions
Tagged with switch-statement if-statement
1,036
questions
0
votes
1
answer
69
views
Which is better in this scenario - if else loop or case in shell scripting?
I am trying to write a shell script which has a part where I have to use some kind of loop to execute some commands if condition satisfy.
I want to understand what is the best way to approach this ...
0
votes
0
answers
10
views
PHP, 2 different interpretations for the same evaluation using if and switch case [duplicate]
in the following code, does anyone know why is the $val === 0 case never running when there's a zero in the $arr array?
<?php
function plusMinus($arr) {
$positiveCount = $zeroCount = $...
0
votes
1
answer
63
views
Immediate break after input using switch or if
I am learning C right now and im at the very beginning.
Here's my code:
#include <stdio.h>
int main (){
char operator;
double num1;
double num2;
double result;
printf("\n Enter an ...
0
votes
1
answer
34
views
Crystal Report If formula with multiple conditions
I'm getting an error message with this formula but can't see the wood for the trees of what's missing - please help!
if {vehinv_rec.master_class_2} = "RCV" and if {vehinv_rec.chassis_model} ...
0
votes
1
answer
17
views
Crystal reports highlighting
I have a field in a Crystal Report that I want to highlight based on multiple Criteria.
I cannot figure out a way to get a switch and/or if statement to work for me.
This is for a productivity report. ...
1
vote
3
answers
57
views
doing operations for else-if "groups"
I had a pattern like this and didn't know a good way to handle it
let i = Math.floor(5 * Math.random())
if (i == 0) {
console.log('a')
console.log('+')
}
else if (i == 1) {
console....
-1
votes
2
answers
75
views
How to execute multiple other cases inside of a case
So it is possible to fall-through the case to another case:
switch(variable) {
case 1:
// do something 1
case 2:
// do something 2
break;
case 3:
// do something 3
break;
}
...
-1
votes
3
answers
54
views
Mysql on duplicate key condition (IF) setting of one field
I am using on duplicate key to update data in a mySQL DB v 8.0.35 (AWS RDS instance)
I want to update a selection of fields with the new value. Plus set a further field (up[dated) to 1 only if a ...
0
votes
1
answer
64
views
Is there any way to convert this if function to switch case type?
if (textLetter.toLowerCase().contains('1')) {
textCodeElec += ' 19';
textLetter = textLetter.substring(1);
}
if (textLetter.toLowerCase().contains('2')) {
textCodeElec += ' ...
0
votes
4
answers
98
views
How do I break out of a while loop from within a switch in an if else statement in C?
I was trying out simple activities about if statements, switches, and loops while studying programming and I ran into this problem.
while (1) {
if (/*condition*/) {
//error
} else {
...
0
votes
1
answer
278
views
Multiple IF Statements in Power BI query for ISFILTERED
I am trying to hide values on a table unless at least one of three slicers is selected.I have scoured the web and it does not seem like any solution is working for me as when I put the measure onto ...
0
votes
0
answers
63
views
Is it possible to have a ternary operator, if,if/else statement and switch statement on 1 src code in Java?
I tried all 4 on 1 src code and my program stops half way through.
here's the code, what did I do wrong?:
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change ...
0
votes
1
answer
80
views
Is there any way to use switch statements for user input? C# [closed]
I'm a beginner so I apologize if this is a dumb question. I just want to reduce the number of if, else if, and else statements and just make it so that it uses switch statements or something. I tried ...
-2
votes
1
answer
85
views
Trying to find the employee who placed the highest bid out of 5 employees
The point of the assignment is to assign all 5 people names and the number of times they bid(must be below or at zero). Then I will need to take those names and numbers and store them so they can then ...
0
votes
0
answers
120
views
How I can dynamically add HTML with if /else or swtich/case conditions
What I'm trying to do :
I want to create an html code generator. The idea is to be able to create an email skeleton, with the possibility for the user, via inputs, to modify certain data, such as the ...