How can I use percentages in a switch condition to represent player status based on health?Using a method from a different classBig Integer multiplication(recursion) in java stops without an error for input of size of the order of 2000 digits. Why?How to prevent cheating with Gamecih?Is it possible to merge these two queries?Finding number of digits before a decimal point in javaChoosing players based on percentageHow not to show the unknown/skipped results in extent reportswitch case array reading - javasoundHow can this method be changed to return a List of Strings rather than a String?Box2D (Processing): how to solve the 'Could not invoke the “beginContact()” method for some reason' error?
shebang or not shebang
What did Varys actually mean?
Crime rates in a post-scarcity economy
Gift for mentor after his thesis defense?
If quadruped mammals evolve to become bipedal will their breast or nipple change position?
In a series of books, what happens after the coming of age?
HTML folder located within IOS Image file?
How can I finally understand the confusing modal verb "мочь"?
Why did Gendry call himself Gendry Rivers?
Why doesn't a particle exert force on itself?
What does “two-bit (jerk)” mean?
Concatenate all values of the same XML element using XPath/XQuery
How does "politician" work as a job/career?
Does this website provide consistent translation into Wookiee?
Translation of "invincible independence"
How to get the decimal part of a number in apex
What does the copyright in a dissertation protect exactly?
Good introductory book to type theory?
Picking a theme as a discovery writer
Make me a minimum magic sum
Select list elements based on other list
A♭ major 9th chord in Bach is unexpectedly dissonant/jazzy
Why is the blank symbol not considered part of the input alphabet of a Turing machine?
Does restarting the SQL Services (on the machine) clear the server cache (for things like query plans and statistics)?
How can I use percentages in a switch condition to represent player status based on health?
Using a method from a different classBig Integer multiplication(recursion) in java stops without an error for input of size of the order of 2000 digits. Why?How to prevent cheating with Gamecih?Is it possible to merge these two queries?Finding number of digits before a decimal point in javaChoosing players based on percentageHow not to show the unknown/skipped results in extent reportswitch case array reading - javasoundHow can this method be changed to return a List of Strings rather than a String?Box2D (Processing): how to solve the 'Could not invoke the “beginContact()” method for some reason' error?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I should preface this by saying I'm VERY new to coding and Java in general; forgive my stupidity! I'm attempting to set up a status system for the player based on how much health they have, wherein their current Status is a String involved in a switch function which changes from "You are doing fine!" to "You are dying!". However, rather than doing it with single digits, I want to do it with percentage of health so the message does not change when they reach 50 or 25 percent health, whether the player has 50 or 10 health max.
Essentially, I want to make it so in place of single variables representing certain values of health in the switch function, percentages of PCHealth do. This is what I don't want, but what I know how to do:
int PCHealth = 10;
String Status = "";
switch (PCHealth)
case 5: Status = "You're fine!";
case 2: Status = "You're dying!";
Here's what I want sketched out in fake code:
int PCHealth = 10;
String Status = "';
switch (PCHealth)
case [50% of PCHealth] = "You're fine!";
case [20 % of PCHealth] = "You're dying!";
Thank you!
java
add a comment |
I should preface this by saying I'm VERY new to coding and Java in general; forgive my stupidity! I'm attempting to set up a status system for the player based on how much health they have, wherein their current Status is a String involved in a switch function which changes from "You are doing fine!" to "You are dying!". However, rather than doing it with single digits, I want to do it with percentage of health so the message does not change when they reach 50 or 25 percent health, whether the player has 50 or 10 health max.
Essentially, I want to make it so in place of single variables representing certain values of health in the switch function, percentages of PCHealth do. This is what I don't want, but what I know how to do:
int PCHealth = 10;
String Status = "";
switch (PCHealth)
case 5: Status = "You're fine!";
case 2: Status = "You're dying!";
Here's what I want sketched out in fake code:
int PCHealth = 10;
String Status = "';
switch (PCHealth)
case [50% of PCHealth] = "You're fine!";
case [20 % of PCHealth] = "You're dying!";
Thank you!
java
you can evaluate those values before switch and store it in a variable and then put that variable inside switch
– Onkar Musale
Mar 23 at 6:00
add a comment |
I should preface this by saying I'm VERY new to coding and Java in general; forgive my stupidity! I'm attempting to set up a status system for the player based on how much health they have, wherein their current Status is a String involved in a switch function which changes from "You are doing fine!" to "You are dying!". However, rather than doing it with single digits, I want to do it with percentage of health so the message does not change when they reach 50 or 25 percent health, whether the player has 50 or 10 health max.
Essentially, I want to make it so in place of single variables representing certain values of health in the switch function, percentages of PCHealth do. This is what I don't want, but what I know how to do:
int PCHealth = 10;
String Status = "";
switch (PCHealth)
case 5: Status = "You're fine!";
case 2: Status = "You're dying!";
Here's what I want sketched out in fake code:
int PCHealth = 10;
String Status = "';
switch (PCHealth)
case [50% of PCHealth] = "You're fine!";
case [20 % of PCHealth] = "You're dying!";
Thank you!
java
I should preface this by saying I'm VERY new to coding and Java in general; forgive my stupidity! I'm attempting to set up a status system for the player based on how much health they have, wherein their current Status is a String involved in a switch function which changes from "You are doing fine!" to "You are dying!". However, rather than doing it with single digits, I want to do it with percentage of health so the message does not change when they reach 50 or 25 percent health, whether the player has 50 or 10 health max.
Essentially, I want to make it so in place of single variables representing certain values of health in the switch function, percentages of PCHealth do. This is what I don't want, but what I know how to do:
int PCHealth = 10;
String Status = "";
switch (PCHealth)
case 5: Status = "You're fine!";
case 2: Status = "You're dying!";
Here's what I want sketched out in fake code:
int PCHealth = 10;
String Status = "';
switch (PCHealth)
case [50% of PCHealth] = "You're fine!";
case [20 % of PCHealth] = "You're dying!";
Thank you!
java
java
asked Mar 23 at 5:54
Jippy HereJippy Here
11
11
you can evaluate those values before switch and store it in a variable and then put that variable inside switch
– Onkar Musale
Mar 23 at 6:00
add a comment |
you can evaluate those values before switch and store it in a variable and then put that variable inside switch
– Onkar Musale
Mar 23 at 6:00
you can evaluate those values before switch and store it in a variable and then put that variable inside switch
– Onkar Musale
Mar 23 at 6:00
you can evaluate those values before switch and store it in a variable and then put that variable inside switch
– Onkar Musale
Mar 23 at 6:00
add a comment |
4 Answers
4
active
oldest
votes
Just do it with if-else
. Its very simple and good to understand.
public String getStatus(int PChealth, int maxValue)
float percent = (PChealth * 1.0f) / maxValue;
if (percent > 75) return "great";
else if (percent > 50) return "mid";
else if (percent > 25) return "not good";
else if (PChealth == 0) return "dead";
else return "bad";
Side notes: The first if
that evalute true
will return the correct value.
Savvy?
add a comment |
/*
Things that you will need to know
- integer division vs double
- type casting
- Math.ceil()
# int division
10/25 --> 0
# double division
10.0/25 --> 0.4
# Math.ceil()
Math.ceil(0.4) --> 1.0
0-25 XXX
25-50 fine
50-75 good
75-100 great
*/
Play with this code, printout things that you don't understand or what value they are holding... I tried to keep things simple.
public class MyClass
private static int maxHealth = 100;
public static String getPlayerHealthStatus(double pHealth)
String pHStatus = "";
int pHealth_case = (int) Math.ceil( pHealth / (maxHealth / 4));
switch (pHealth_case)
case 4:
pHStatus = "You're doing great!";
break;
case 3:
pHStatus = "You're doing good!";
break;
case 2:
pHStatus = "You're fine!";
break;
case 1:
pHStatus = "You're dying!";
break;
case 0:
pHStatus = "You died!";
break;
default:
pHStatus = "invalid player health";
return pHStatus;
public static void main(String args[])
int playerHealth = 90;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 70;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 40;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 20;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 0;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
Output:
player health: 90 status: You're doing great!
player health: 70 status: You're doing good!
player health: 40 status: You're fine!
player health: 20 status: You're dying!
player health: 0 status: You died!
add a comment |
Its not possible to have expressions in case statements, use if-else
statements or like @Onkar said store them in a separate variable.
if-else
should be cleaner for your use case.
add a comment |
I would store the max health in the variable MaxHealth
then try the following switch! :)
Here we have if
statement in the switch
statement, that will do case 1 if the health is between 0 and 20% and so on
double PCHealth = __ ;
switch (((0 <= PCHealth && PCHealth <= (0.2 * MaxHealth)) ? 0 :
((0.2 * MaxHealth) > PCHealth && (0.5 * MaxHealth) < PCHealth) ? 1 : 2)
case 0:
Status = "You're dying!";
break;
case 1:
Status = "You're fine!";
break;
case 2:
Status = "You're doing excelent";
break;
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311044%2fhow-can-i-use-percentages-in-a-switch-condition-to-represent-player-status-based%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Just do it with if-else
. Its very simple and good to understand.
public String getStatus(int PChealth, int maxValue)
float percent = (PChealth * 1.0f) / maxValue;
if (percent > 75) return "great";
else if (percent > 50) return "mid";
else if (percent > 25) return "not good";
else if (PChealth == 0) return "dead";
else return "bad";
Side notes: The first if
that evalute true
will return the correct value.
Savvy?
add a comment |
Just do it with if-else
. Its very simple and good to understand.
public String getStatus(int PChealth, int maxValue)
float percent = (PChealth * 1.0f) / maxValue;
if (percent > 75) return "great";
else if (percent > 50) return "mid";
else if (percent > 25) return "not good";
else if (PChealth == 0) return "dead";
else return "bad";
Side notes: The first if
that evalute true
will return the correct value.
Savvy?
add a comment |
Just do it with if-else
. Its very simple and good to understand.
public String getStatus(int PChealth, int maxValue)
float percent = (PChealth * 1.0f) / maxValue;
if (percent > 75) return "great";
else if (percent > 50) return "mid";
else if (percent > 25) return "not good";
else if (PChealth == 0) return "dead";
else return "bad";
Side notes: The first if
that evalute true
will return the correct value.
Savvy?
Just do it with if-else
. Its very simple and good to understand.
public String getStatus(int PChealth, int maxValue)
float percent = (PChealth * 1.0f) / maxValue;
if (percent > 75) return "great";
else if (percent > 50) return "mid";
else if (percent > 25) return "not good";
else if (PChealth == 0) return "dead";
else return "bad";
Side notes: The first if
that evalute true
will return the correct value.
Savvy?
answered Mar 23 at 7:47
user6537157user6537157
388214
388214
add a comment |
add a comment |
/*
Things that you will need to know
- integer division vs double
- type casting
- Math.ceil()
# int division
10/25 --> 0
# double division
10.0/25 --> 0.4
# Math.ceil()
Math.ceil(0.4) --> 1.0
0-25 XXX
25-50 fine
50-75 good
75-100 great
*/
Play with this code, printout things that you don't understand or what value they are holding... I tried to keep things simple.
public class MyClass
private static int maxHealth = 100;
public static String getPlayerHealthStatus(double pHealth)
String pHStatus = "";
int pHealth_case = (int) Math.ceil( pHealth / (maxHealth / 4));
switch (pHealth_case)
case 4:
pHStatus = "You're doing great!";
break;
case 3:
pHStatus = "You're doing good!";
break;
case 2:
pHStatus = "You're fine!";
break;
case 1:
pHStatus = "You're dying!";
break;
case 0:
pHStatus = "You died!";
break;
default:
pHStatus = "invalid player health";
return pHStatus;
public static void main(String args[])
int playerHealth = 90;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 70;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 40;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 20;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 0;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
Output:
player health: 90 status: You're doing great!
player health: 70 status: You're doing good!
player health: 40 status: You're fine!
player health: 20 status: You're dying!
player health: 0 status: You died!
add a comment |
/*
Things that you will need to know
- integer division vs double
- type casting
- Math.ceil()
# int division
10/25 --> 0
# double division
10.0/25 --> 0.4
# Math.ceil()
Math.ceil(0.4) --> 1.0
0-25 XXX
25-50 fine
50-75 good
75-100 great
*/
Play with this code, printout things that you don't understand or what value they are holding... I tried to keep things simple.
public class MyClass
private static int maxHealth = 100;
public static String getPlayerHealthStatus(double pHealth)
String pHStatus = "";
int pHealth_case = (int) Math.ceil( pHealth / (maxHealth / 4));
switch (pHealth_case)
case 4:
pHStatus = "You're doing great!";
break;
case 3:
pHStatus = "You're doing good!";
break;
case 2:
pHStatus = "You're fine!";
break;
case 1:
pHStatus = "You're dying!";
break;
case 0:
pHStatus = "You died!";
break;
default:
pHStatus = "invalid player health";
return pHStatus;
public static void main(String args[])
int playerHealth = 90;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 70;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 40;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 20;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 0;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
Output:
player health: 90 status: You're doing great!
player health: 70 status: You're doing good!
player health: 40 status: You're fine!
player health: 20 status: You're dying!
player health: 0 status: You died!
add a comment |
/*
Things that you will need to know
- integer division vs double
- type casting
- Math.ceil()
# int division
10/25 --> 0
# double division
10.0/25 --> 0.4
# Math.ceil()
Math.ceil(0.4) --> 1.0
0-25 XXX
25-50 fine
50-75 good
75-100 great
*/
Play with this code, printout things that you don't understand or what value they are holding... I tried to keep things simple.
public class MyClass
private static int maxHealth = 100;
public static String getPlayerHealthStatus(double pHealth)
String pHStatus = "";
int pHealth_case = (int) Math.ceil( pHealth / (maxHealth / 4));
switch (pHealth_case)
case 4:
pHStatus = "You're doing great!";
break;
case 3:
pHStatus = "You're doing good!";
break;
case 2:
pHStatus = "You're fine!";
break;
case 1:
pHStatus = "You're dying!";
break;
case 0:
pHStatus = "You died!";
break;
default:
pHStatus = "invalid player health";
return pHStatus;
public static void main(String args[])
int playerHealth = 90;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 70;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 40;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 20;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 0;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
Output:
player health: 90 status: You're doing great!
player health: 70 status: You're doing good!
player health: 40 status: You're fine!
player health: 20 status: You're dying!
player health: 0 status: You died!
/*
Things that you will need to know
- integer division vs double
- type casting
- Math.ceil()
# int division
10/25 --> 0
# double division
10.0/25 --> 0.4
# Math.ceil()
Math.ceil(0.4) --> 1.0
0-25 XXX
25-50 fine
50-75 good
75-100 great
*/
Play with this code, printout things that you don't understand or what value they are holding... I tried to keep things simple.
public class MyClass
private static int maxHealth = 100;
public static String getPlayerHealthStatus(double pHealth)
String pHStatus = "";
int pHealth_case = (int) Math.ceil( pHealth / (maxHealth / 4));
switch (pHealth_case)
case 4:
pHStatus = "You're doing great!";
break;
case 3:
pHStatus = "You're doing good!";
break;
case 2:
pHStatus = "You're fine!";
break;
case 1:
pHStatus = "You're dying!";
break;
case 0:
pHStatus = "You died!";
break;
default:
pHStatus = "invalid player health";
return pHStatus;
public static void main(String args[])
int playerHealth = 90;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 70;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 40;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 20;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
playerHealth = 0;
System.out.println("player health: "+playerHealth+" status: "+getPlayerHealthStatus(playerHealth));
Output:
player health: 90 status: You're doing great!
player health: 70 status: You're doing good!
player health: 40 status: You're fine!
player health: 20 status: You're dying!
player health: 0 status: You died!
edited Mar 25 at 18:34
answered Mar 23 at 6:38
Tanmay jainTanmay jain
72949
72949
add a comment |
add a comment |
Its not possible to have expressions in case statements, use if-else
statements or like @Onkar said store them in a separate variable.
if-else
should be cleaner for your use case.
add a comment |
Its not possible to have expressions in case statements, use if-else
statements or like @Onkar said store them in a separate variable.
if-else
should be cleaner for your use case.
add a comment |
Its not possible to have expressions in case statements, use if-else
statements or like @Onkar said store them in a separate variable.
if-else
should be cleaner for your use case.
Its not possible to have expressions in case statements, use if-else
statements or like @Onkar said store them in a separate variable.
if-else
should be cleaner for your use case.
edited Mar 23 at 6:46
answered Mar 23 at 6:39
HariUserXHariUserX
1,1231515
1,1231515
add a comment |
add a comment |
I would store the max health in the variable MaxHealth
then try the following switch! :)
Here we have if
statement in the switch
statement, that will do case 1 if the health is between 0 and 20% and so on
double PCHealth = __ ;
switch (((0 <= PCHealth && PCHealth <= (0.2 * MaxHealth)) ? 0 :
((0.2 * MaxHealth) > PCHealth && (0.5 * MaxHealth) < PCHealth) ? 1 : 2)
case 0:
Status = "You're dying!";
break;
case 1:
Status = "You're fine!";
break;
case 2:
Status = "You're doing excelent";
break;
add a comment |
I would store the max health in the variable MaxHealth
then try the following switch! :)
Here we have if
statement in the switch
statement, that will do case 1 if the health is between 0 and 20% and so on
double PCHealth = __ ;
switch (((0 <= PCHealth && PCHealth <= (0.2 * MaxHealth)) ? 0 :
((0.2 * MaxHealth) > PCHealth && (0.5 * MaxHealth) < PCHealth) ? 1 : 2)
case 0:
Status = "You're dying!";
break;
case 1:
Status = "You're fine!";
break;
case 2:
Status = "You're doing excelent";
break;
add a comment |
I would store the max health in the variable MaxHealth
then try the following switch! :)
Here we have if
statement in the switch
statement, that will do case 1 if the health is between 0 and 20% and so on
double PCHealth = __ ;
switch (((0 <= PCHealth && PCHealth <= (0.2 * MaxHealth)) ? 0 :
((0.2 * MaxHealth) > PCHealth && (0.5 * MaxHealth) < PCHealth) ? 1 : 2)
case 0:
Status = "You're dying!";
break;
case 1:
Status = "You're fine!";
break;
case 2:
Status = "You're doing excelent";
break;
I would store the max health in the variable MaxHealth
then try the following switch! :)
Here we have if
statement in the switch
statement, that will do case 1 if the health is between 0 and 20% and so on
double PCHealth = __ ;
switch (((0 <= PCHealth && PCHealth <= (0.2 * MaxHealth)) ? 0 :
((0.2 * MaxHealth) > PCHealth && (0.5 * MaxHealth) < PCHealth) ? 1 : 2)
case 0:
Status = "You're dying!";
break;
case 1:
Status = "You're fine!";
break;
case 2:
Status = "You're doing excelent";
break;
edited Mar 23 at 6:51
answered Mar 23 at 6:36
StrazanStrazan
53113
53113
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55311044%2fhow-can-i-use-percentages-in-a-switch-condition-to-represent-player-status-based%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you can evaluate those values before switch and store it in a variable and then put that variable inside switch
– Onkar Musale
Mar 23 at 6:00