Xi Prac

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

IF ELSE PROGRAM

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");
}

else if(marks>=70 && marks<80)


{
System.out.println("B grade");
}
else if(marks>=80 && marks<90)
{
System.out.println("A grade");
}
else if(marks>=90 && marks<100)
{
System.out.println("A+ grade");
}
else
{
System.out.println("Invalid!");
}
}
}

OUTPUT:
Enter the mark 90
A+ grade
Enter the mark 55
D grade
Enter the mark 65
C grade

SWITCH CASE STATEMENT

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:

Enter the alphabet a

It is a vowel

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy