Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Please HELP me URGENT

Posted by shoyeb4me (shoyeb4me), 15 October 2006
I am a novish in Java Wolrd. I m trying to learn it. Anyway I am getting one problem while I am trying to solve one

problem. The problem is

First you have create an array A of unsorted random integers and will have to repoduce an array B which contains

all integres from A without repetitions.

For example, given array A = [1,2,5,6,6,3,3,2,9,6,8], the program will produce array B = [1,2,5,6,3,9,8] where no

repetitions are allowed .



If anybody please help me by providing code I will be very happy and greatful.It will help me to learn.

Thank u all.

Posted by admin (Graham Ellis), 15 October 2006
Post up your code so far, and we'll have a look.  

By the way ... you shout that your requirement is urgent.   We look at questions within 24 hours on this forum - if you need something quicker than that, I would suggest you ask elsewhere.

Posted by shoyeb4me (shoyeb4me), 15 October 2006
import java.io.*;
import java.util.*;

class RandomInteger
{
     public int[] rnd;
     public static boolean InChk = false;
     public int gArray=0;


     public static void main(String args[])
     {
           RandomInteger ran = new RandomInteger();      
           ran.getRandomArray();
   }

     }

     public int getIntegerArraySize(String s)
     {
           String s;
           BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
           System.out.println(s);
           
     }

     public void getRandomArray()
     {
           int ArraySize=0;
           
           do
           {
                 InChk=false;
                 arr=gar("how many numbers");
           }
           while(InChk==true);
           rnd = new int [arr];

           for(int i=0; i<arr; i++)
           {
                 rnd[i]=(int)(Math.random()*10);
                 System.out.println(" ["+(i+1)+"] = "+rnd[i]);

           }
           
     }



i did that so far. please help me. its not urgent within 24hr. if it takes time its ok but if u could plz help me in a week. thanks a lot

Posted by admin (Graham Ellis), 15 October 2006
Looks like you could do it with two nested loops - outer loop to check each element in turn, inner loop to see if it's already been copied across; here's an example of the algorithm in Perl for you to translate.

Code:
for ($k=0; $k<20; $k++) {
       $vt[$k] = int(rand()* 15.0);
       }
print ("@vt\n");

@result = ();

for ($k=0; $k<@vt; $k++) {
       $dup = 0;
       for ($j=0; $j<@result; $j++) {
               $dup = 1 if ($result[$j] == $vt[$k]);
       }
       $dup or push @result,$vt[$k];
}
print ("@result\n");


earth-wind-and-fire:~/oct06 grahamellis$ perl plsh
9 11 10 0 11 8 8 0 0 13 4 14 1 2 10 8 8 2 14 3
9 11 10 0 8 13 4 14 1 2 3
earth-wind-and-fire:~/oct06 grahamellis$

Posted by ac3buddy (ac3buddy), 10 January 2007
I need a source code for a java program that converts a time in a 12 hour notation to 24 hour notation and vice versa in javax.swing

1.Create a file, Time.java using a text editor that will accepts time in 24-hour notation and output in 12-hour notation via console and using  javax.swing package. A sample run are given below:

Sample Run 1:
Input time in 24-hour notation: 0101
Equivalent time in 12-hour notation: 1:01 a.m

Sample Run 2:
Input time in 24-hour notation: 0900
Equivalent time in 12-hour notation: 9:00 a.m

Sample Run 3:
Input time in 24-hour notation: 1430
Equivalent time in 12-hour notation: 2:30 p.m


Posted by admin (Graham Ellis), 10 January 2007
Hello, ac3buddy.

If you post up a sample of the code you're trying and describe the problems it's giving you, we'll try and help you.   Typically, we respond here within 24 hours to such requests. If you need something quicker, you're probably going to be better asking elsewhere / using a paid support service.



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho