Xi Prac
Xi Prac
Xi Prac
PROGRAM:
import
java.util.Scanner; public
class IfElse
{
public static void main(String[] args)
{
int marks;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the
Mark"); mark=sc.nextint();
if(marks<50)
{
System.out.println("fail");
}
else if(marks>=50 && marks<60)
{
System.out.println("D grade");
}
else if(marks>=60 && marks<70)
{
System.out.println("C grade");
}
OUTPUT:
Enter the mark 90
A+ grade
Enter the mark 55
D grade
Enter the mark 65
C grade
PROGRAM:
import
java.util.Scanner; public
class switchcase
{
public static void main(String[] args)
{
char ch;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the Alphabet Letter ");
ch= sc.next().charAt(0);
switch(ch)
{
case 'a':
System.out.println("Vowel");
break;
case 'e':
System.out.println("Vowel");
break;
case 'i':
System.out.println("Vowel");
break;
case 'o':
System.out.println("Vowel");
break;
case 'u':
System.out.println(“Vowel”); break;
Case ‘A’:
System.out.println(“Vowel”);
break;
Case ‘E’:
System.out.println(“Vowel”);
break;
Case ‘I’:
System.out.println(“Vowel”);
break;
Case ‘O’:
System.out.println(“Vowel”);
break;
Case ‘U’:
System.out.println(“Vowel”);
break;
Default:
System.out.println(“Consonant”);
OUTPUT:
It is a vowel