English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

import java.io.*;
public class homework{

public static void main(String[] args) throws IOException{
BufferedReader sulat = new BufferedReader (new FileReader("pakshit"));
String ian;

String[] jiji = new String[4];
int i = 0;
while ((ian = sulat.readLine()) != null ){
String moo;
char mqq;
mqq = ian.charAt(0);
moo = Character.toString(mqq);
jiji[i++] = moo;
int val = (int)mqq;
System.out.println(val);




}
}
}
____

pakshit textfie contains:

Justin
Nadine
Adrian
Vincent
___
it prints the converted first letters to its coresponding number:

74
78
65
86
____
my prob is how to sort these numbers in ascending order and print the coresponding name also in ascending order which will now print:

Adrian
Justin
Nadine
Vincent
______
hope u guys can help me =)

2007-02-14 03:34:16 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

import java.io.*;

public class homework{

public static void main(String[] args) throws IOException{
BufferedReader sulat = new BufferedReader (new FileReader("pakshit.txt"));
String ian;
String[] name =new String[4];
int a = 0;
int b = 0;
int ab= 0;

int val[]= new int[4];
while ((ian = sulat.readLine()) != null ){

name[a++]=ian;
}

java.util.Arrays.sort(name); //to sort array alphabetically

for ( String part: name ){
char newmqq=part.charAt(0);
val[b++] = (int)newmqq;
System.out.println( String.valueOf(val[ab++]));
}
for ( String part: name ){
System.out.println( String.valueOf( part ) );
}
}
}
// The Solution
// From: Just Do It S

2007-02-14 04:55:18 · answer #1 · answered by Geinius 3 · 0 0

public static void main(String[] args) throws IOException{
BufferedReader sulat = new BufferedReader (new FileReader("pakshit"));
String ian; HangSystem

String[] jiji = new String[4];
int i = 0;
while ((ian = sulat.readLine()) != null ){
String moo;
Do Stuff((Lots)) = More
char mqq;
HangSystem = false; CrashSystem Again;
mqq = ian.charAt(0);
moo = Character.toString(mqq);
delte OS/2; Boot Windows 3.1
jiji[i++] = moo;
Fill Cache;
int val = (int)mqq;
Set.Mousespeed(veryslow)
set.mouseactions(jumpy)
System.out.println(val);


.

}
}
}

2007-02-14 03:43:28 · answer #2 · answered by Say Bye 1 · 0 1

test

2007-02-14 03:39:24 · answer #3 · answered by coolnaveen 2 · 0 0

JAVA DAY ONE ! HEATHER NICOLE AND SAMANTHA JANE

2007-02-14 03:36:39 · answer #4 · answered by Sammi 3 · 0 0

fedest.com, questions and answers