Java World: Questions And Solutions (java Only Pls)

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 23, 2009, 12:22 AM
431014 members and 298085 Topics
Latest Member: love6238
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Java World: Questions And Solutions (java Only Pls)
Pages: (1) (2) Go Down Send this topic Notify of replies
Author Topic: Java World: Questions And Solutions (java Only Pls)  (Read 1408 views)
Hardballer (m)
Re: Java World: Questions And Solutions (java Only Please)
« #32 on: May 21, 2008, 11:25 PM »

wld really appreciate help  with this assignment im in a real fix

 
Write a complete address book maintenance application. The user of the program has three options: add new person, delete a person and modify the data of a person.
You have to decide how to allow the user to enter the values for a new person, and the other options.
You must use files in order to save and read the data.

Use the  AddressBook class provided below.

the address book class
/*
    Introduction to OOP with Java 4th Ed, McGraw-Hill

    Wu/Otani

    Chapter 10 Sample Program: Address Book Maintenance

    File: AddressBook.java
*/

/**
 * This class is designed to manage an address book that contains
 * Person objects. The user can specify the size of the address book
 * when it is created. If no size is specified, then the default size
 * is set to 25 Person objects.
 *
 * @author Dr. Caffeine
 *
 */
class AddressBook  {    //Step 4: Implement the delete method


//--------------------------------
//    Data Members
//--------------------------------

    /**
     * Default size of the array
     */
    private static final int  DEFAULT_SIZE = 25;

    /**
     * Constant for signaling an unsuccessful search
     */
    private static final int  NOT_FOUND    = -1;

    /**
     * The array of Person objects
     */
    private Person[]   entry;

    /**
     * The number of elements in the <code>entry</code> array,
     * which is also the position to add the next Person object
     */
    private int        count;

//--------------------------------
//    Constructors
//--------------------------------

    /**
     * Default constructor.
     * Creates an address book of size 25.
     */
    public AddressBook( ) {
        this( DEFAULT_SIZE );
    }


    /**
     * Creates an address book with the designated size.
     *
     * @param size the size of this address book.
     */
    public AddressBook( int size ){
        if (size <= 0 ) {
            throw new IllegalArgumentException("Size must be positive.");
        }

        entry = new Person[size];

        //System.out.println("Array of "+ size + " is created."); //TEMP
    }


//-------------------------------------------------
//      Public Methods:
//
//          void    add       (   Person     )
//          void    delete    (   String     )
//          Person  search    (   String     )
//
//------------------------------------------------

    /**
     * Adds a new Person to this address book.
     * If the overflow occurs, the array size
     * is increased by 50 percent.
     *
     * @param newPerson a new Person object to add
     */
    public void add( Person newPerson ) {

        assert count >= 0 && count <= entry.length;

        if (count == entry.length) {   //no more space left,
            enlarge( );                //create a new larger array
        }

        //at this point, entry refers to a new larger array
        entry[count] = newPerson;
        count++;
    }


    /**
     * Deletes the Person whose name is 'searchName'.
     *
     * @param searchName the name of a Person to delete
     *
     * @return true if removed successfully; false otherwise
     */
    public boolean delete( String searchName )
    {
        boolean    status;
        int        loc;

        loc = findIndex( searchName );

        if (loc == NOT_FOUND) {
            status = false;
        } else { //found, pack the hole

            entry[loc] = entry[count-1];

            status = true;
            count--;        //decrement count,
                            //since we now have one less element
            assert count >= 0 && count <= entry.length;
        }

        return status;
    }

    /**
     * Searches this address book for a Person
     * whose name is <code>searchName</code>.
     *
     * @param searchName the name to search
     *
     * @return a Person object if found; otherwise null
     */
    public Person search( String searchName ) {
        Person foundPerson;
        int         loc = 0;

        while ( loc < count &&
                !searchName.equals( entry[loc].getName() ) ) {
            loc++;
        }

        if (loc == count) {

            foundPerson = null;
        } else {

            foundPerson = entry[loc];
        }

        return foundPerson;
    }

//-------------------------------------------------
//      Private Methods:
//
//          void  enlarge   (           )
//
//------------------------------------------------

    /**
     * Enlarges the size of <code>entry</code> array to
     * eliminate the overflow condition. The new array
     * is 50 percent larger than the current array.
     */
    private void enlarge( ) {
        //create a new array whose size is 150% of
        //the current array
        int newLength = (int) (1.5 * entry.length);
        Person[] temp = new Person[newLength];

        //now copy the data to the new array
        for (int i = 0; i < entry.length; i++) {
            temp[i] = entry[i];
        }

        //finally set the variable entry to point to the new array
        entry = temp;

        System.out.println("Inside the method enlarge");            //TEMP
        System.out.println("Size of a new array: " + entry.length); //TEMP
    }

    /**
     * Finds the index in the array where <code>searchName</code>
     * is the name of a person to locate.
     *
     * @param searchName the name of person to find
     *
     * @return the index of the found Person in the array; NOT_FOUND
     *         if the searched person is not found
     */
    private int findIndex( String searchName ) {
        int loc = 0;

        while ( loc < count &&
                !searchName.equals( entry[loc].getName() ) ) {
            loc++;
        }

        if (loc == count) {

            loc = NOT_FOUND;
        }

        return loc;
    }
}

please mail me at push_thetempo@hotmail.com
Bossman (m)
Re: Java World: Questions And Solutions (java Only Please)
« #33 on: May 21, 2008, 11:54 PM »

Exactly what part do you need hep with? It looks like you were provided with a good portion of what you need. What have you tried to do and are having difficulty with?
Hardballer (m)
Re: Java World: Questions And Solutions (java Only Please)
« #34 on: May 22, 2008, 10:02 AM »

see thts the thing the lecturer dint cover arrays and files in his lectures(he says we shd go and buy the txtbook) so i really dont know hw to go about it and this assignment is like 15%  of the whole mark. I just need the solution to the question
javaprince (m)
Re: Java World: Questions And Solutions (java Only Please)
« #35 on: May 31, 2008, 02:07 PM »

@logica
Thatz not a good answer.

iReport comes with documentation but not enough to inform me on how to embed it within Netbeans JFrame forms
Moreso I though this was a Question & answer forum.
bjccole (m)
Re: Java World: Questions And Solutions (java Only Please)
« #36 on: July 14, 2008, 05:38 PM »

Dear Java Gurus,

How do I represent logic circuit diagram in Java. I can perform the manual hand written work but how do I implement it in Java.

Please you can contact on bjccole@gmail.com.

Thanks.
Ghenghis (m)
Re: Java World: Questions And Solutions (java Only Please)
« #37 on: July 14, 2008, 08:24 PM »

If your talking about implementing your logic diagram its not difficult since that's the building block for all computers.

You have logical AND,OR and negation operators that behave live the normal logic gates.

Since you've not provided details I'm guessing you have a digital circuit already ,

You can then use the SUM OF PRODUCTS (or PRODUCT OF, ) to build your logic

But i must admit its all concept ,  lets hear more details !
bjccole (m)
Re: Java World: Questions And Solutions (java Only Please)
« #38 on: July 17, 2008, 10:28 AM »

These are the questions:

1,Write a program in java with the following input and output given the value of 2 boolean varriable x,y use the program to find x+y, x(+)y and xy

2,To construct a table listing of set of value of all 256 of boolean fucnction for  3 varriable

3, Write a program that can generate a boolean function where the varriable maybe up to a degree of 4
SayoMarvel (m)
Re: Java World: Questions And Solutions (java Only Please)
« #39 on: July 20, 2008, 11:47 PM »

Watzup to y'all beginners aspiring to become professional coders, it may look uninteresting at the beginning but as time goes on(when you start working with GUI toolkits) you will see that its fun. I strongly recommend this book for all of you, "JAVA HOW TO PROGRAM". Anybody that knows it will testify. As stated above do not start using IDEs now, it will make u less of a programmer because you are not yet rooted in the game. When you people are now good(i.e able to construct algorithms and write full working codes without bugs, then you can start using IDEs, even JAVA HOW TO PROGRAM will not introduce you to IDEs at the beginning of the book but for your knowledge, try to read online articles about NetBeans, Eclipse, Sun StudioCreator etc. Try to write codes to solve simple problems and before you know it, you're on your way. Good luck.
SayoMarvel (m)
Re: Java World: Questions And Solutions (java Only Please)
« #40 on: July 20, 2008, 11:58 PM »

sorry, it wasn't here i wanted to post. i'm very sorry for disorganising this thread.
bjccole (m)
Re: Java World: Questions And Solutions (java Only Please)
« #41 on: July 21, 2008, 09:59 AM »

Dear Java Gurus,

Please I need answers to the questions above.

Thanks you so much for your anticipated ideas and contributions.
sbucareer (f)
Re: Java World: Questions And Solutions (java Only Please)
« #42 on: July 21, 2008, 10:28 AM »

x
freeranger (m)
Re: Java World: Questions And Solutions (java Only Please)
« #43 on: August 01, 2008, 12:27 PM »

hello
i'm new in java
pls can anyone help me with java
video tutorials.
i ll be very grateful.
malone5923 (m)
Re: Java World: Questions And Solutions (java Only Please)
« #44 on: August 03, 2008, 09:22 AM »

Hi, Is it possible to get the seed value for sets of number like 5(not randomly generated). I have checked the Api for java but I can only get methods for setting  seed values.
javaprince (m)
Re: Java World: Questions And Solutions (java Only Please)
« #45 on: August 03, 2008, 05:39 PM »

@malone
Quote from: malone5923 on August 03, 2008, 09:22 AM
Hi, Is it possible to get the seed value for sets of number like 5(not randomly generated). I have checked the Api for java but I can only get methods for setting seed values.

I don't quite get your question, but if am thinking what you are thiking? Then why would you want to get the seed values? That means u are thinking of reverse engineering. i.e Gettin the Seed Values from a given set of numbers so that u can now generate your own numbers then probably hack into something? Hope thatz not what u mean? Anyway, the way random numbers are been generated its a little deeper than that, and I don't think u can get the seed value from randomly generated values. And secured systems do not use a fixed Random generated number and they still perform some other numeric manipulations to d nos. So forget that line of thinking.

Have you heard of JAND? Java Nigerian Developers? Its a community of Nigerian Developers/Programmers better join at www.naijadukes.net/jand/ . See u there.
malone5923 (m)
Re: Java World: Questions And Solutions (java Only Please)
« #46 on: August 03, 2008, 09:38 PM »

Quote
I don't quite get your question, but if am thinking what you are thinking? Then why would you want to get the seed values? That means u are thinking of reverse engineering. i.e Gettin the Seed Values from a given set of numbers so that u can now generate your own numbers then probably hack into something? Hope that's not what u mean? Anyway, the way random numbers are been generated its a little deeper than that, and I don't think u can get the seed value from randomly generated values. And secured systems do not use a fixed Random generated number and they still perform some other numeric manipulations to d nos. So forget that line of thinking.
Reverse engineering what the hell do I need that for(not saying is useless) if I want to add new features to stuffs I prefer creating then having full authority   
over the features that will be installed. To tell the truth I just wanted to know and I was also reading an example for class Random in the examples that comes with the jdk when you install it and I came a across method getSeed() funny does developers at sun never seem to be a fan of good program readability.
   And Yes I have checked out the jand(nice acronym) website and I must confess, please don't find this offence but if you want your community to grow you don't have to talk about how nice the community is(I KNOW THATS WHY TYPED THE URL) or how nice the concept of having a Java community in naija. Instead you post question that you feel will attract programmers thats the only reason they will register but if you continue with selfappraisal about the website you will only end up with 10 visit per month.
javaprince (m)
Re: Java World: Questions And Solutions (java Only Please)
« #47 on: August 04, 2008, 10:12 AM »

@malone
Thanks so much for your advice. The truth is the community is very new, and has just begun to grow. The site forum is so simple, and still has very few contributors. But to make it grow, we need support and contributions from Java Programmers/Developers. And remember the forum is just an easy way for members of the community to express themselves and not the MAIN focus.

We just want a community where nigerian java developers can share ideas, experiences, info, learn, etc.

Once again thanks.
malone5923 (m)
Re: Java World: Questions And Solutions (java Only Please)
« #48 on: August 13, 2008, 05:29 PM »

Quote
@malone
Thanks so much for your advice. The truth is the community is very new, and has just begun to grow. The site forum is so simple, and still has very few contributors. But to make it grow, we need support and contributions from Java Programmers/Developers. And remember the forum is just an easy way for members of the community to express themselves and not the MAIN focus.

We just want a community where nigerian java developers can share ideas, experiences, info, learn, etc.

Once again thanks.
Thank you for not taking my comment offensive.
     How can I pick of digits form 5 Int numbers that are typed by the user with three spaces seperating them as in: 45489 to 4   5   4   8   9. Using only division and module operand. I will appreciate if you use peseudocode to answer my questions.
rock101 (m)
Re: Java World: Questions And Solutions (java Only Please)
« #49 on: August 14, 2008, 12:33 PM »

hey, can I learn Java (or programming basicly) without havin to study any computer related course at a University or having to attend some other training. Aside from the tutorials at sun.java.com, where else can I get help? I have interest in Computers and all that but my problem is I'm not the reading type. The tutorials at the java site are quite lengthy, I'll be more interested in something practical. If my only choice is to read the whole tutorial, WTF!, I damn will, but for now I'm looking for an alternative. Please give me a very practical answer, as I said earlier I am more than interested in computers.
javarules (m)
Re: Java World: Questions And Solutions (java Only Please)
« #50 on: August 17, 2008, 07:25 AM »

Come join the latest in Java Movememnt, yes a JUG has started in Nigeria and its right here


http://naijadukes.net

All your java problems solved and more,


be there,
Ghenghis (m)
Re: Java World: Questions And Solutions (java Only Please)
« #51 on: August 17, 2008, 05:03 PM »

Quote from: malone5923 on August 13, 2008, 05:29 PM
     How can I pick of digits form 5 Int numbers that are typed by the user with three spaces seperating them as in: 45489 to 4   5   4   8   9. Using only division and module operand. I will appreciate if you use peseudocode to answer my questions.

You're outsourcing your homework  Grin

Ok, I'll give you some tips (not in pseudocode)
primary 1 stuff
Since you're using the decimal system :
example 1:
   H T U
   4 5 7
+ 2 5 9
--------
  7 1 6
-------
example 2:
you'll notice that meaning ( 4 x 100) + (5 x 10) + (7)
plus (2 x 100) + ( 5 x 10) + (9)

457 / 100 = 4 REM 57
57 / 10 = 5 REM 7
7/1 = 7

You'll wish you paid more attention in primary 1  Shocked (Good luck)
javarules (m)
Re: Java World: Questions And Solutions (java Only Please)
« #52 on: August 18, 2008, 12:46 AM »

Quote from: malone5923 on August 13, 2008, 05:29 PM
     How can I pick of digits form 5 Int numbers that are typed by the user with three spaces seperating them as in: 45489 to 4   5   4   8   9. Using only division and module operand. I will appreciate if you use peseudocode to answer my questions.

I think this problem has a simple solution. The one I will provide will solve for n length of string(replace n with 5 or whatever u like)

0. Start
1. Get d length of the String, n
2. raise 10 to the power of n, power
3. convert string to Integer, num
4. while num > 0
       divide num by power, adigit
       print  adigit
       print a single space
       let num => remainder of the above division ///i.e num = num % power
       let power = power/10 ///i.e divide power by 10, the shift operators may come in handy here if u want to use them, but the spec say only div and mod, we'll stick to that
5.    Print "This solution was provided on NairaLand, sponsored by JAND http://www.naijadukes.net/"
6.    Exit

Hope that works,

ciao
Quote from: rock101 on August 14, 2008, 12:33 PM
hey, can I learn Java (or programming basicly) without havin to study any computer related course at a University or having to attend some other training. Aside from the tutorials at sun.java.com, where else can I get help? I have interest in Computers and all that but my problem is I'm not the reading type. The tutorials at the java site are quite lengthy, I'll be more interested in something practical. If my only choice is to read the whole tutorial, WTF!, I damn will, but for now I'm looking for an alternative. Please give me a very practical answer, as I said earlier I am more than interested in computers.
Yes u can, but dont expect it to be a piece of cake, in my own view programming is different from everything, even computer science!!  bite me if u want, dts just my view

Help, try http://naijadukes.net

Read read read and read, you are going nowhere without it, even programming has got big books, so my man, u gat to read

Finally, if u gat pple around u who have gone a bit ahead, dt cud help u alot. dts what naijadukes is meant to do

ciao
malone5923 (m)
Re: Java World: Questions And Solutions (java Only Please)
« #53 on: August 21, 2008, 01:51 PM »

Quote
You're outsourcing your homework 

Ok, I'll give you some tips (not in pseudocode)
primary 1 stuff
Since you're using the decimal system :
example 1:
   H T You
   4 5 7
+ 2 5 9
--------
  7 1 6
-------
example 2:
you'll notice that meaning ( 4 x 100) + (5 x 10) + (7)
plus (2 x 100) + ( 5 x 10) + (9)

457 / 100 = 4 REM 57
57 / 10 = 5 REM 7
7/1 = 7

You'll wish you paid more attention in primary 1   (Good luck)
If I had paid more attention in primary 1 I might have understood your point but I was to busy with something I really cant remember.
Primary 1 RULES!!!
And I am not outsourcing my homework(If I had any).
malone5923 (m)
Re: Java World: Questions And Solutions (java Only Please)
« #54 on: August 21, 2008, 02:01 PM »

Quote
think this problem has a simple solution. The one I will provide will solve for n length of string(replace n with 5 or whatever u like)

0. Start
1. Get d length of the String, n
2. raise 10 to the power of n, power
3. convert string to Integer, num
4. while num > 0
       divide num by power, adigit
       print  adigit
       print a single space
       let num => remainder of the above division ///i.e num = num % power
       let power = power/10 ///i.e divide power by 10, the shift operators may come in handy here if u want to use them, but the spec say only div and mod, we'll stick to that
5.    Print "This solution was provided on NairaLand, sponsored by JAND http://www.naijadukes.net/"
6.    Exit

Hope that works,

ciao
I know I just dont want to convert the integer to string I want the int value to be manipulated without any need to convert it to string.
gorociano (m)
Re: Java World: Questions And Solutions (java Only Please)
« #55 on: August 21, 2008, 02:46 PM »

dudes, thanks for starting this thread for java newbies like moi, using JAVA how to program 2007 edition  and i'm already thinking in java (i.e i'm a subclass of my dad's family and i implement the class "mummy").
trying to develop a software for cafe management and someone recommended freeradius (on naijadukes.net, cant understand why the site no dey go again) but the problem is i dont know a shit about what freeredius is except that it's a open source program that run on linux.can anyone with experience of using it gimme the loaddown about how to dowload and use it??
Your in JAVA
Femmy Johnson
gorociano@gmail.com
gorociano (m)
Re: Java World: Questions And Solutions (java Only Please)
« #56 on: August 21, 2008, 03:08 PM »

guys , abeg what certification exams can one write as a java programmer???
malone5923 (m)
Re: Java World: Questions And Solutions (java Only Please)
« #57 on: August 21, 2008, 03:51 PM »

Quote
You're outsourcing your homework 

Ok, I'll give you some tips (not in pseudocode)
primary 1 stuff
Since you're using the decimal system :
example 1:
   H T You
   4 5 7
+ 2 5 9
--------
  7 1 6
-------
example 2:
you'll notice that meaning ( 4 x 100) + (5 x 10) + (7)
plus (2 x 100) + ( 5 x 10) + (9)

457 / 100 = 4 REM 57
57 / 10 = 5 REM 7
7/1 = 7

You'll wish you paid more attention in primary 1   (Good luck)
After going back to my primary 1 maths textbook I finally cracked. I guess Primary school wasnt has useless as I thought it was
Primary 1 RULES
Bossman (m)
Re: Java World: Questions And Solutions (java Only Please)
« #58 on: August 21, 2008, 03:56 PM »

There are several. You first need to start with the Programmer Certification (SCJP), then you can go fo rthe others as you choose. The SCJP is a prerequisite for the other Java certifications offered by Sun.

Here are some forums dedicated to the exams.

http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?category=7

Quote from: gorociano on August 21, 2008, 03:08 PM
guys , abeg what certification exams can one write as a java programmer???
lucianoefe (m)
Re: Java World: Questions And Solutions (java Only Please)
« #59 on: August 21, 2008, 04:56 PM »

hello once again, i've got a question that has been buggin me since i started my project. pls, can any one, i repeat, any programmer tell me which is beta to implement a multimedia application( image or sound), c++ or java? i really need a reply, its urgent. u guys r my last hope and all i ve,
                    worried me.

Cry
 The Importance Of Software Testing And Not Just Software Programming  Difference Between Db_flashback_retention_target And Retention Policy  Collection Of Nigerian Programming Gurus  Page 2
Pages: (1) (2) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.