based on the switch case not calling activity properly in android
Date : March 29 2020, 07:55 AM
I wish this helpful for you Hi in the below code when I am clicking general registration report it was showing the last one .when I am clicking the second activity then also showing last activity. case 0:
Intent i=new Intent(getApplicationContext(),General_report.class);
startActivity(i);
break;
case 1:
Intent i1=new Intent(getApplicationContext(),Ipd_report.class);
startActivity(i1);
break;
case 2:
Intent i11=new Intent(getApplicationContext(),Opd_report.class);
startActivity(i11);
break;
|
Calling a function within a switch case
Tag : c , By : James Lupiani
Date : March 29 2020, 07:55 AM
hope this fix your issue Several Issues: You need to declare functions before you use them. #include<stdio.h>
int sum(int a,int b);
int substact(int a,int b);
int multiplay(int a,int b);
double devision(int a,int b);
int main()
{
int operation,fc,v1,v2;
double fcd;
printf("input 2 values\n");
scanf("%d%d",&v1,&v2);
/* telling the user to choose any type of calculator */
printf("please choose what you want to do with your values\n");
printf("1- Sum\n");
printf("2- substracttion\n");
printf("3- multiplay\n");
printf("4- devision\n");
scanf("%d",&operation);//input a
switch(operation)
{
case 1:
fc = sum(v1, v2);
printf("sum of two values = %d\n",fc);
break;
case 2:
fc = substact(v1, v2);
printf("substract of two values = %d",fc);
break;
case 3:
fc = multiplay(v1, v2);
printf("multiply of two values = %d\n",fc);
break;
case 4:
fcd = devision(v1, v2);
printf("division of two values = %d\n",fc);
break;
default:
printf("wrong choice\n");
}
return 0;
}
int sum(int a,int b)
{
int sum=0;
sum=a+b;
return sum;
}
int substact(int a,int b)
{
int sub=0;
sub=a-b;
return sub;
}
int multiplay(int a,int b)
{
int mult=1;
mult=a*b;
return mult;
}
double devision(int a,int b)
{
double devi=1;
devi=a/b;
return devi;
}
|
Trying to use a switch case similarity in Python, but somehow first choice always runs first
Tag : python , By : Kubla Khan
Date : March 29 2020, 07:55 AM
Hope that helps I am aware that Python doesn't have a switch case like C++, but I'm trying to figure out how to go about it and found something, but not sure if it's implemented correctly. , Here's a working example of your code: def choiceone():
print("choiceone")
def choicetwo():
print("choicetwo")
def default():
print("default")
def switching(x):
return {
1: choiceone,
2: choicetwo,
}.get(x, default)
if __name__ == "__main__":
user_input = int(input("Choice: "))
your_choice = switching(user_input)
your_choice()
|
Calling a switch case function from inside HTML
Date : March 29 2020, 07:55 AM
it should still fix some issue You need to make the ID available to the function. You could also change the echo's to return's as you are using an echo in the | and it is always better to return data from a function rather than have the function generate output itself. function tank_IDs ($tankId) {
switch ($tankId) {
case "3649":
return '<img class="tanks" src="tank_1.png"/>';
//...
default:
return '<img class="tanks" src="tank_2.png"/>';
}
}
<td><?php echo tank_IDs($tank_stats['tank_id']); ?></td>
|
Embedded C - Choice between switch/case & hashtable
Date : March 29 2020, 07:55 AM
|