Lab1
import java.util.Scanner;
class Lab1 {
public static void main(String args[]) {
//announce variable
String grade_temp;
char grade;
//setup input method
Scanner grade_temp_input = new Scanner (System.in);
//show input
System.out.print("Enter Grade :: ");
grade_temp = grade_temp_input.nextLine();
//convert string to char and uper case
grade = grade_temp.toUpperCase().charAt(0);
//construction
switch (grade) {
case 'A' : System.out.println("Excallent"); break;
case 'B' : System.out.println("Good"); break;
case 'C' : System.out.println("Bad"); break;
default : System.out.println("Invalid");
}
}
} |
import java.util.Scanner;
class Lab1 {
public static void main(String args[]) {
//announce variable
String grade_temp;
char grade;
//setup input method
Scanner grade_temp_input = new Scanner (System.in);
//show input
System.out.print("Enter Grade :: ");
grade_temp = grade_temp_input.nextLine();
//convert string to char and uper case
grade = grade_temp.toUpperCase().charAt(0);
//construction
switch (grade) {
case 'A' : System.out.println("Excallent"); break;
case 'B' : System.out.println("Good"); break;
case 'C' : System.out.println("Bad"); break;
default : System.out.println("Invalid");
}
}
}
Lab2
import java.util.Scanner;
class Lab2 {
public static void main(String args[]) {
//announce variable
int month,year;
//setup input method
Scanner month_input = new Scanner (System.in);
Scanner year_input = new Scanner (System.in);
//show input
System.out.print("Enter your month :: ");
month = month_input.nextInt();
System.out.print("Enter your year :: ");
year = year_input.nextInt();
//construction
switch (month) {
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10 :
case 12 :
System.out.println("Days = 31"); break;
case 4 :
case 6 :
case 9 :
case 11 :
System.out.println("Days = 30"); break;
case 2 :
if (((year%4==0)&&!(year%100==0))||(year%400==0)) {
System.out.println("Days : 29");
}else{
System.out.println("Days : 28");
} break;
}
//end
}
} |
import java.util.Scanner;
class Lab2 {
public static void main(String args[]) {
//announce variable
int month,year;
//setup input method
Scanner month_input = new Scanner (System.in);
Scanner year_input = new Scanner (System.in);
//show input
System.out.print("Enter your month :: ");
month = month_input.nextInt();
System.out.print("Enter your year :: ");
year = year_input.nextInt();
//construction
switch (month) {
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10 :
case 12 :
System.out.println("Days = 31"); break;
case 4 :
case 6 :
case 9 :
case 11 :
System.out.println("Days = 30"); break;
case 2 :
if (((year%4==0)&&!(year%100==0))||(year%400==0)) {
System.out.println("Days : 29");
}else{
System.out.println("Days : 28");
} break;
}
//end
}
}
Test1
import java.util.Scanner;
class Test1 {
public static void main(String[] args) {
//announce variable
int number1,number2;
//setup input method
Scanner number1_input = new Scanner (System.in);
Scanner number2_input = new Scanner (System.in);
//show input
System.out.print("Enter Number 1 >>> ");
number1 = number1_input.nextInt();
System.out.print("Enter Number 2 >>> ");
number2 = number2_input.nextInt();
//construction
switch(number1) {
case 1 : System.out.println("One"); break;
case 2 : System.out.println("Two");
if (number2 >= 10) {
System.out.println("Max");
}else{
System.out.println("Min");
} break;
case 3 : System.out.println("Three"); break;
default : System.out.println("Invalid");
//end
}
}
} |
import java.util.Scanner;
class Test1 {
public static void main(String[] args) {
//announce variable
int number1,number2;
//setup input method
Scanner number1_input = new Scanner (System.in);
Scanner number2_input = new Scanner (System.in);
//show input
System.out.print("Enter Number 1 >>> ");
number1 = number1_input.nextInt();
System.out.print("Enter Number 2 >>> ");
number2 = number2_input.nextInt();
//construction
switch(number1) {
case 1 : System.out.println("One"); break;
case 2 : System.out.println("Two");
if (number2 >= 10) {
System.out.println("Max");
}else{
System.out.println("Min");
} break;
case 3 : System.out.println("Three"); break;
default : System.out.println("Invalid");
//end
}
}
}
Test2
import java.util.Scanner;
class Test2 {
public static void main(String[] args) {
//announce variable
String string1;
char char1;
int number1;
//setup input method
Scanner string1_input = new Scanner (System.in);
Scanner number1_input = new Scanner (System.in);
//show input
System.out.print("Enter Letter >>> ");
string1 = string1_input.nextLine();
System.out.print("Enter Number2 >>> ");
number1 = number1_input.nextInt();
//convert string to char
char1 = string1.toUpperCase().charAt(0);
//construction
switch(char1) {
case 'A' : System.out.println("One"); break;
case 'B': System.out.println("Two");
if (number1 >= 10) {
System.out.println("Max");
}else{
System.out.println("Min");
} break;
case 'C' : System.out.println("Three"); break;
default : System.out.println("Invalid");
//end
}
}
} |
import java.util.Scanner;
class Test2 {
public static void main(String[] args) {
//announce variable
String string1;
char char1;
int number1;
//setup input method
Scanner string1_input = new Scanner (System.in);
Scanner number1_input = new Scanner (System.in);
//show input
System.out.print("Enter Letter >>> ");
string1 = string1_input.nextLine();
System.out.print("Enter Number2 >>> ");
number1 = number1_input.nextInt();
//convert string to char
char1 = string1.toUpperCase().charAt(0);
//construction
switch(char1) {
case 'A' : System.out.println("One"); break;
case 'B': System.out.println("Two");
if (number1 >= 10) {
System.out.println("Max");
}else{
System.out.println("Min");
} break;
case 'C' : System.out.println("Three"); break;
default : System.out.println("Invalid");
//end
}
}
}