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

import java.io.

*;

import java.util.*;

class Rearrange {

private String wrd;

private String newwrd;

public Rearrange() {

wrd = new String();

newwrd = new String();

public void readword() throws IOException {

Scanner sc = new Scanner(System.in);

System.out.print("Enter the word:");

wrd = sc.next();

public void freq_vow_con() {

wrd = wrd.toUpperCase();

int v = 0;

int c = 0;

for (int i = 0; i < wrd.length(); i++) {

char ch = wrd.charAt(i);

if(Character.isLetter(ch)) {

switch(ch) {

case 'A':

case'E':

case 'I':

case 'O':

case 'U':

v++;

break;

default:

c++;

}}}

System.out.println("Frequency of vowels: "+v);

System.out.println("Frequency of consonants: "+c);


}

public void arrange() {

String v = new String();

String c = new String();

wrd = wrd.toUpperCase();

for(int i = 0; i < wrd. length(); i++) {

char ch = wrd.charAt(i);

if(Character.isLetter(ch)) {

switch(ch) {

case 'A':

case'E':

case 'I':

case 'O':

case 'U':

v += ch;

break;

default:

c =c+ ch;

newwrd = v + c;

public void display() {

System.out.println("Original word:" + wrd);

System.out.println("Rearranged word:" + newwrd);

public static void main(String args[])throws IOException {

Rearrange obj = new Rearrange();

obj.readword();

obj.freq_vow_con();

obj.arrange();

obj.display();

}}
class Merger

long n1; long n2;

long mergNum;

public Merger()

n1=1;

n2=1;

mergNum=11;

public void readNum()

Scanner sc=new Scanner(System.in);

System.out.print("Enter first number:");

n1=(int)Math.abs(sc.nextLong());

System.out.print("Enter second number:");

n2=(int)Math.abs(sc.nextLong());

if(n1==0)

n1=1;

if(n2==0)

n2=1;

public void joinNum()

String num1 = Long.toString(n1);

String num2 = Long.toString(n2);

String merged=num1 + num2;

mergNum=Long.parseLong(merged);

public void show()

System.out.println("First Number: "+n1);

System.out.println("Second Number: "+n2);

System.out.println("Merged Number: "+mergNum);


}

public static void main(String args[])

Merger obj=new Merger();

obj.readNum();

obj.joinNum();

obj.show();

}
import java.io.*;

class ConsChange {

String word;

int len;

public ConsChange() {

word = new String ();

len = word.length ();

public void readword () throws IOException {

InputStreamReader isr = new InputStreamReader (System.in);

BufferedReader br = new BufferedReader (isr);

System.out.println ("Enter the word");

word = br.readLine();

word = word.trim().toLowerCase();

if (word.indexOf (' ') > 0)

word = word.substring (0, word.indexOf (' '));

len = word.length();

public void shiftcons()

String cons = new String();

String vowel = new String();

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

char ch = word.charAt (i);

switch (ch)

case 'a':

case 'e':

case 'i':

case 'o':

case 'u':

vowel += ch;

break;
default:

cons += ch ;

word = cons + vowel;

System.out.println ("Shifted Word"+word);

changeword();

System.out.println("Changed Word: "+ word);

public void changeword()

int pos = -1;

char ch=' ';

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

ch = word.charAt (i);

switch (ch)

case 'a':

case 'e':

case 'o':

case 'u':

break;

default:

pos = ch;

word = word.substring (0, pos + 1). toUpperCase ()+word.substring (pos + 1);

}
class Record

String n[];

int m[];

int size;

public Record(int cap) {

size=cap;

public void readarray() {

public void display() {

class Highest extends Record {

private int ind;

public Highest(int cap) {

super(cap);

public void find() {

ind = 0;

for (int i = 0; i < size; i++)

{ if(m[i]>m[ind]){

ind = i;

public void display() {

super.display();

System.out.println("Highest marks are::" +m[ind]);

System.out.println("Students who score the highest marks are::");

for (int i = 0; i < size; i++) {

if(m[i] == m[ind]) {

System.out.println(n[i]);

}}}}

You might also like