Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class nrp5213100155 {
- public static void main(String[]args){
- abjad uji = new abjad();
- }
- }
- class abjad{
- public Scanner me = new Scanner (System.in);
- int array [];
- String huruf;
- private void rumus (){
- for (int i=0;i<huruf.length()-1;i++){
- if (huruf.charAt(i)==',') //agar dapat menerima input berupa tanda koma (,)
- huruf = huruf.substring(0,i) + huruf.substring (i+1); //memisah angka dan huruf
- }
- }
- private void hola (){
- for (int i=0;i<huruf.length();i++){
- if(huruf.codePointAt(i)>=49&&huruf.codePointAt(i)<=57)
- array[i]=(huruf.codePointAt(i))*2+97; //Input Angka
- else
- array[i]=(huruf.codePointAt(i))*2;
- }
- }
- private void huhu(){
- int temp;
- for (int i=huruf.length()-1;i>0;i--){ //buublesort
- for (int x=0;x<i;x++){
- if(array[i]<array[x]){
- temp = array[i];
- array[i]=array[x];
- array[x]=temp;
- }
- }
- }
- }
- private void info(){
- char temp;
- for (int i = 0; i < huruf.length(); i++) {
- if(array[i]%2==0)
- temp = (char) (array[i]/2);
- else
- temp = (char) ((array[i]-97)/2);
- if(i!=huruf.length()-1)
- System.out.print(temp+",");
- else
- System.out.println(temp);
- }
- }
- abjad(){
- System.out.print("Inputan : ");
- huruf = me.nextLine();
- rumus();
- array = new int[huruf.length()]; //output
- hola();
- huhu();
- System.out.print("Hasil Pengurutan : ");
- info();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement