Computer Science, asked by Albatroz007, 8 months ago

Define a class Arrange described as below:

Data members/instance variables:

String str (a word)
String i
int p (to store the length of the word)
char ch;
Member Methods:

A parameterised constructor to initialize the data member
To accept the word
To arrange all the alphabets of word in ascending order of their ASCII values without using the sorting technique
To display the arranged alphabets.
Write a main method to create an object of the class and call the above member methods.

Answers

Answered by rockerzzzop
0

Answer:

Explanation:

import java.util.*;

class ASCII_Sorting

{

public static void main(String args[])

{

int i=0;String s="";int j=0;

Scanner sc=new Scanner(System.in);

s=sc.next();

int ascii[]=new int[s.length()];

for(i=0;i<s.length();i++)

{

ascii[i]=(int)s.charAt(i);

}

for(i=32;i<=126;i++)

{

for(j=0;j<ascii.length;j++)

{

if(i==ascii[j])

{

System.out.print((char)ascii[j]);

}

}

}

}

}

Similar questions