0% found this document useful (0 votes)
36 views4 pages

First Term Programs

Uploaded by

Ved Ramesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

First Term Programs

Uploaded by

Ved Ramesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1st Program

//pair of vowels

class Firstterm1

int c=0, len;

char ch1,ch2;

void main(String s)

s=s.toUpperCase();

len=s.length();

for (int i=0;i<len-1;i++)

ch1=s.charAt(i);

ch2=s.charAt(i+1);

if ((ch1=='A' || ch1 =='E' || ch1 =='I' || ch1 =='O' || ch1 =='U') && (ch2=='A' || ch2 =='E' ||
ch2 =='I' || ch2 =='O' || ch2 =='U'))

System.out.println(ch1+" "+ch2);

c=c+1;

System.out.println("Total pairs of vowels="+c);

}
2nd Program
//to print the palindrome between two given numbers

import java.util.*;

class Palindrome

void main(String[]args)

int b,r=0,n;

Scanner sc=new Scanner(System.in);

System.out.println("Enter the palindrome No.");

int N=sc.nextInt();

System.out.print("Palindrome number from 1 to N");

for(int i=1;i<=N;i++)

n=i;

while(n>0)

b=n%10;

r=r*10+b;

n=n/10;

if(r==i)

System.out.print(i+" ");

r=0;

}
}

3rd Program
//menu driven

import java.util.*;

class Menu

Scanner sc=new Scanner(System.in);

int ch,k;

void main()

System.out.println("1 Number pattern");

System.out.println("2 Character pattern");

System.out.println("Enter your choice..");

ch=sc.nextInt();

switch (ch)

case 1:

k=1;

for (int i=1;i<=4;i++)

for (int j=1;j<=i;j++)

System.out.print(k+" ");

k++;

}
System.out.println();

break;

case 2:

char k='A';

for (int i=1;i<=4;i++)

for (int j=1;j<=i;j++)

System.out.print(k+" ");

k++;

System.out.println();

break;

default :

System.out.println("wrong choice");

You might also like