The Artima Developer Community
Sponsored Link

Java Answers Forum
Sorting & Printing Arrays-Please help!

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Claire

Posts: 1
Nickname: clayclay
Registered: Mar, 2002

Sorting & Printing Arrays-Please help! Posted: Mar 29, 2002 5:09 AM
Reply to this message Reply
Advertisement
As you will all probably recognise from my much jumbled and incoherent program i am only new to this programming lark and am extremely stuck at the moment.my program is supposed to read a sequence of lines each containing a name, telephone no. and then generates a telephone directory. iv to create a class Person which represents the idea of a person and input of 1000 lines must be catered for. at the moment my program has about 18 errors, all of which i cannot resolve. Any help would be much appreciated.



class Person
{
String forename,surname,number;

void getPerson()
{
forename = Console.readToken();
surname = Console.readString();
number = Console.readString();
}
void print()
{
column = (surname+","+forename
+" ";
System.out.println(column.substring(0,20)+number);


{
void SortChars(char [] a)
int lft = 0;

while(lft<a.length-1)
{
int min = lft;
int i = lft+1;

while(i<a.length)
{
if(a<a[min])
{
min = i;
}
i++;
}

char temp;
temp = count[lft];
a[lft] = a[min];
a[min] = temp;
lft++;
}
}

static boolean Sorting(Person b, Person c)
{
if(b.surname).compareTo(c.surname)<0)
return true;
else if((b.surname).compareTo(c.surname)=0)&&
(b.forename).compareTo(c.forename<0)
return true;
else
return false;
}

public static void main(String [] args)
{
Person [] human = new Person[1000];
int humanSize = 0;

while(!Console.EndOfFile())
{
for(int i = 0; i < humanSize; i++)
{
Person z = new Person[];
z.getPerson();
human = z;
humanSize++;
}
}
Person [] new human = new Person ;
int x = 0;

while(x<i)
{
new Human [x] = Human x;
x++;
SortChars(new Person z);
}
}
}
}

Topic: Help on read input file from Java Previous Topic   Next Topic Topic: serial communication

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use