Switch Case Example
Berikut adalah source code untuk mencari Switch Case Example pada java dengan menggunakan netbeans.
source code :
public static void main(String[] args) {
grading('A');
grading('C');
grading('E');
grading('G');
}
public static void grading(char grade) {
int success;
switch (grade) {
case 'A':
System.out.println("Excellentgrade"); success = 1; break;
case 'B':
System.out.println("Very goodgrade"); success = 1; break;
case 'C':
System.out.println("Goodgrade"); success = 1;
break; case 'D': case
'E': case 'F':
System.out.println("Low grade");
success =
0; break;
default:
System.out.println("Invalid grade");
success = -1;
break;
}
passTheCourse(success);
}
public static void passTheCourse(int success)
{ switch (success) {
}
}
}
output :
source code :
public static void main(String[] args) {
grading('A');
grading('C');
grading('E');
grading('G');
}
public static void grading(char grade) {
int success;
switch (grade) {
case 'A':
System.out.println("Excellentgrade"); success = 1; break;
case 'B':
System.out.println("Very goodgrade"); success = 1; break;
case 'C':
System.out.println("Goodgrade"); success = 1;
break; case 'D': case
'E': case 'F':
System.out.println("Low grade");
success =
0; break;
default:
System.out.println("Invalid grade");
success = -1;
break;
}
passTheCourse(success);
}
public static void passTheCourse(int success)
{ switch (success) {
}
}
}
output :
Komentar
Posting Komentar