Search Results

Search found 874 results on 35 pages for 'scanner'.

Page 25/35 | < Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >

  • How to structure an application which reads UPC barcodes

    - by tugberk
    I have no previous experience on creating a project for a seller which will use barcode reader. I am trying to put together a small project but I cannot figure out how the pieces should glue together. I will create a sample with Motorola Scanner SDK to read barcodes and from that point, I have couple of questions: How UPC barcodes work in general? AFAIK, a barcode stores the manufacturer and product info but no price data. Should I store price information inside a database which corresponds to barcode data? I would really appreciate if you can guide me here.

    Read the article

  • How to re-partition?

    - by EDi
    I switched from Windows to Ubuntu 4 months ago and I am really happy with it. I set up a dual-boot system (since I wasn´t sure how it will end up with me and Ubuntu). After merging from Citavi to Zotero I need windows only for my scanner. The problem I have now is, that the windows partion is so big with lots of unused space and the ubuntu partition are quite small - I should have though about this problem 4 months ago... My partitions look like this: Where sda3 is the windows partition, sda5 is Ubuntu and sda7 is a data partition. I want to shrink sda3 and free some space for sda5 and sda3. How can this be done safely (and easily)?

    Read the article

  • Silverlight 4 Default Button Service

    - by Mark Cooper
    For a few months I have been successfully using David Justices Default Button example in my SL 3 app. This approach is based on an attached property. After upgrading to SL4, the approach no longer works, and I get a XAML exception: "Unknown parser error: Scanner 2148474880" Has anyone succesfully used this (or any other) default button attached behaviours in SL4? Is there any other way to achieve default button behaviour in SL4 with the new classes that are available? Thanks, Mark

    Read the article

  • Bluetooth APIs in Windows/.Net?

    - by cjkarr
    I am in the process of writing a Bluetooth scanner that locates and identifies mobile devices in the local vicinity. Is this something that I can accomplish using C#, or do I need to drop down into the C/C++ APIs? My application is targeting Windows XP and Vista. Pointers are appreciated. Thanks!

    Read the article

  • Communicating between C# application and Android app via bluetooth

    - by Akki
    The android application acts as a server in this case. I have a main activity which creates a Thread to handle serverSocket and a different thread to handle the socket connection. I am using a uuid common to C# and android. I am using 32feet bluetooth library for C#. The errors i am facing are 1) My logcat shows this debug log Error while doing socket.connect()1 java.io.IOException: File descriptor in bad state Message: File descriptor in bad state Localized Message: File descriptor in bad state Received : Testing Connection Count of Thread is : 1 2) When i try to send something via C# app the second time, this exception is thrown: A first chance exception of type 'System.InvalidOperationException' occurred in System.dll System.InvalidOperationException: BeginConnect cannot be called while another asynchronous operation is in progress on the same Socket. at System.Net.Sockets.Socket.DoBeginConnect(EndPoint endPointSnapshot, SocketAddress socketAddress, LazyAsyncResult asyncResult) at System.Net.Sockets.Socket.BeginConnect(EndPoint remoteEP, AsyncCallback callback, Object state) at InTheHand.Net.Bluetooth.Msft.SocketBluetoothClient.BeginConnect(BluetoothEndPoint remoteEP, AsyncCallback requestCallback, Object state) at InTheHand.Net.Sockets.BluetoothClient.BeginConnect(BluetoothEndPoint remoteEP, AsyncCallback requestCallback, Object state) at InTheHand.Net.Sockets.BluetoothClient.BeginConnect(BluetoothAddress address, Guid service, AsyncCallback requestCallback, Object state) at BTSyncClient.Form1.connect() in c:\users\----\documents\visual studio 2010\Projects\TestClient\TestClient\Form1.cs:line 154 I only know android application programming and i designed the C# by learning bit and pieces. FYI, My android phone is galaxy s with ICS running on it.Please point out my mistakes.. Source codes : C# Code using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Threading; using System.Net.Sockets; using InTheHand.Net.Bluetooth; using InTheHand.Windows.Forms; using InTheHand.Net.Sockets; using InTheHand.Net; namespace BTSyncClient { public partial class Form1 : Form { BluetoothClient myself; BluetoothDeviceInfo bTServerDevice; private Guid uuid = Guid.Parse("00001101-0000-1000-8000-00805F9B34FB"); bool isConnected; public Form1() { InitializeComponent(); if (BluetoothRadio.IsSupported) { myself = new BluetoothClient(); } } private void Form1_Load(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { connect(); } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { try { myself.GetStream().Close(); myself.Dispose(); } catch (Exception ex) { Console.Out.WriteLine(ex); } } private void button2_Click(object sender, EventArgs e) { SelectBluetoothDeviceDialog dialog = new SelectBluetoothDeviceDialog(); DialogResult result = dialog.ShowDialog(this); if(result.Equals(DialogResult.OK)){ bTServerDevice = dialog.SelectedDevice; } } private void callback(IAsyncResult ar) { String msg = (String)ar.AsyncState; if (ar.IsCompleted) { isConnected = myself.Connected; if (myself.Connected) { UTF8Encoding encoder = new UTF8Encoding(); NetworkStream stream = myself.GetStream(); if (!stream.CanWrite) { MessageBox.Show("Stream is not Writable"); } System.IO.StreamWriter mywriter = new System.IO.StreamWriter(stream, Encoding.UTF8); mywriter.WriteLine(msg); mywriter.Flush(); } else MessageBox.Show("Damn thing isnt connected"); } } private void connect() { try { if (bTServerDevice != null) { myself.BeginConnect(bTServerDevice.DeviceAddress, uuid, new AsyncCallback(callback) , message.Text); } } catch (Exception e) { Console.Out.WriteLine(e); } } } } Server Thread import java.io.IOException; import java.util.UUID; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothServerSocket; import android.bluetooth.BluetoothSocket; import android.util.Log; public class ServerSocketThread extends Thread { private static final String TAG = "TestApp"; private BluetoothAdapter btAdapter; private BluetoothServerSocket serverSocket; private boolean stopMe; private static final UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); //private static final UUID uuid = UUID.fromString("6e58c9d5-b0b6-4009-ad9b-fd9481aef9b3"); private static final String SERVICE_NAME = "TestService"; public ServerSocketThread() { stopMe = false; btAdapter = BluetoothAdapter.getDefaultAdapter(); try { serverSocket = btAdapter.listenUsingRfcommWithServiceRecord(SERVICE_NAME, uuid); } catch (IOException e) { Log.d(TAG,e.toString()); } } public void signalStop(){ stopMe = true; } public void run(){ Log.d(TAG,"In ServerThread"); BluetoothSocket socket = null; while(!stopMe){ try { socket = serverSocket.accept(); } catch (IOException e) { break; } if(socket != null){ AcceptThread newClientConnection = new AcceptThread(socket); newClientConnection.start(); } } Log.d(TAG,"Server Thread now dead"); } // Will cancel the listening socket and cause the thread to finish public void cancel(){ try { serverSocket.close(); } catch (IOException e) { } } } Accept Thread import java.io.IOException; import java.io.InputStream; import java.util.Scanner; import android.bluetooth.BluetoothSocket; import android.util.Log; public class AcceptThread extends Thread { private BluetoothSocket socket; private String TAG = "TestApp"; static int count = 0; public AcceptThread(BluetoothSocket Socket) { socket = Socket; } volatile boolean isError; String output; String error; public void run() { Log.d(TAG, "AcceptThread Started"); isError = false; try { socket.connect(); } catch (IOException e) { Log.d(TAG,"Error while doing socket.connect()"+ ++count); Log.d(TAG, e.toString()); Log.d(TAG,"Message: "+e.getLocalizedMessage()); Log.d(TAG,"Localized Message: "+e.getMessage()); isError = true; } InputStream in = null; try { in = socket.getInputStream(); } catch (IOException e) { Log.d(TAG,"Error while doing socket.getInputStream()"); Log.d(TAG, e.toString()); Log.d(TAG,"Message: "+e.getLocalizedMessage()); Log.d(TAG,"Localized Message: "+e.getMessage()); isError = true; } Scanner istream = new Scanner(in); if (istream.hasNextLine()) { Log.d(TAG, "Received : "+istream.nextLine()); Log.d(TAG,"Count of Thread is : " + count); } istream.close(); try { in.close(); } catch (IOException e) { Log.d(TAG,"Error while doing in.close()"); Log.d(TAG, e.toString()); Log.d(TAG,"Message: "+e.getLocalizedMessage()); Log.d(TAG,"Localized Message: "+e.getMessage()); isError = true; } try { socket.close(); } catch (IOException e) { Log.d(TAG,"Error while doing socket.close()"); Log.d(TAG, e.toString()); Log.d(TAG,"Message: "+e.getLocalizedMessage()); Log.d(TAG,"Localized Message: "+e.getMessage()); isError = true; } } }

    Read the article

  • Silverlight 4 Default Button Service

    - by Mark Cooper
    For a few months I have been successfully using David Justices Default Button example in my SL 3 app. This approach is based on an attached property. After upgrading to SL4, the approach no longer works, and I get a XAML exception: "Unknown parser error: Scanner 2148474880" Has anyone succesfully used this (or any other) default button attached behaviours in SL4? Is there any other way to achieve default button behaviour in SL4 with the new classes that are available? Thanks, Mark

    Read the article

  • FileReader File not Found Java

    - by Lucas Camargo de Carvalho
    I have done everything I know. The file is not a ".filetype.filetype". It is in the same folder as the .settings and the other project files. Why is this not working? Full path isn't working either, but strangely, a Scanner is working. import java.io.FileReader; public class test { public static void main(String[] args) { FileReader testFileReader = new FileReader("hotels.json"); } }

    Read the article

  • Point of Sale how to add quantity v2

    - by Jimmy nguyen
    Problem - I have Point of Sale V9 -intuit When ringing up a customer by using a barcode scanner for 1 item and the customer wants multiple of that same item but the receipt shows a long list of that same item. How can I get that program to set it where it would just self update without having to physically touching the keyboard or mouse I would pretty much want it to be user friendly Also if there is a code for this where do I put in the code?

    Read the article

  • Passing array into constructor to use on JList

    - by OVERTONE
    I know the title sound confusing and thats because it is. its a bit long so try too stay with me. this is the layout i have my code designed variables constructor methods. im trying too fill a Jlist full on names. i want too get those names using a method. so here goes. in my variables i have my JList. its called contactNames; i also have an array which stores 5 strings which are the contacts names; heres the code for that anyway String contact1; String contact2; String contact3; String contact4; String contact5; String[] contactListNames; JList contactList; simple enough. then in my constructor i have the Jlist defined to fill itself with the contents of the array fillContactList(); JList contactList = new JList(contactListNames); that method fillContactList() is coming up shortly. notice i dont have the array defined in the constructor. so heres my first question. can i do that? define the array to contain something in te constructor rather than filling it fromt the array. now heres where stuff gets balls up. ive created three different methods all of which havent worked. basically im trying to fill the array with all of them. this is the simplest one. it doesnt set the Jlist, it doesnt do anything compilicated. all it trys too do is fill the array one bit at a time public void fillContactList() { for(int i = 0;i<3;i++) { try { String contact; System.out.println(" please fill the list at index "+ i); Scanner in = new Scanner(System.in); contact = in.next(); contactListNames[i] = contact; in.nextLine(); } catch(Exception e) { e.printStackTrace(); } } } unfortunately this doesnt qwork. i get the print out to fill it at index 0; i input something and i get a nice big stack trace starting at contactListNames[i] = contact; so my two questions in short are how i define an array in a constructor. and why cant i fill the array from that method. ************************888 **************************888 stack trace by request please fill the list at index 0 overtone java.lang.NullPointerException please fill the list at index 1 at project.AdminMessages.fillContactList(AdminMessages.java:408) at project.AdminMessages.<init>(AdminMessages.java:88) at project.AdminUser.createAdminMessages(AdminUser.java:32) at project.AdminUser.<init>(AdminUser.java:18) at project.AdminUser.main(AdminUser.java:47) it was a null poiinter exception

    Read the article

  • Zxing project as library in a project won't build

    - by iie
    ( again ) I want to use the ZXing library in my project, I followed this tutorial http://damianflannery.wordpress.com/2011/06/13/integrate-zxing-barcode-scanner-into-your-android-app-natively-using-eclipse/ [ only difference I'm using netbeans ]after building zxing android project and marking it as a library, I wanted to od it as a library in my own project. After doing it, I can't build it. It looks like the R file can't be created in both [library and myProject ] for example: error: constant expression required case R.id.zxinglib_auto_focus:

    Read the article

  • How to crop scanned image using C#?

    - by ieaglle
    I have a scanned image of a book page and i need to crop this scan for leaving only page area. I tried to use AForge to detect page borders, but it doesn't work because the space which i need to crop may consist of little "light" areas (due to scanner quality) and edge detector detects borders there. That's why this is bad idea as for me. Could you recommend something? P.S. Please don't tell me to use non-free libraries.

    Read the article

  • Java Runtime.freeMemory() returning bizarre results when adding more objects

    - by Sotirios Delimanolis
    For whatever reason, I wanted to see how many objects I could create and populate a LinkedList with. I used Runtime.getRuntime().freeMemory() to get the approximation of free memory in my JVM. I wrote this: public static void main(String[] arg) { Scanner kb = new Scanner(System.in); List<Long> mem = new LinkedList<Long>(); while (true) { System.out.println("Max memory: " + Runtime.getRuntime().maxMemory() + ". Available memory: " + Runtime.getRuntime().freeMemory() + " bytes. Press enter to use more."); String s = kb.nextLine(); if (s.equals("m")) for (int i = 0; i < 1000000; i++) { mem.add(new Long((new Random()).nextLong())); } } } If I write in m, the app adds a million Long objects to the list. You would think the more objects (to which we have references, so can't be gc'ed), the less free memory. Running the code: Max memory: 1897725952. Available memory: 127257696 bytes. m Max memory: 1897725952. Available memory: 108426520 bytes. m Max memory: 1897725952. Available memory: 139873296 bytes. m Max memory: 1897725952. Available memory: 210632232 bytes. m Max memory: 1897725952. Available memory: 137268792 bytes. m Max memory: 1897725952. Available memory: 239504784 bytes. m Max memory: 1897725952. Available memory: 169507792 bytes. m Max memory: 1897725952. Available memory: 259686128 bytes. m Max memory: 1897725952. Available memory: 189293488 bytes. m Max memory: 1897725952. Available memory: 387686544 bytes. The available memory fluctuates. How does this happen? Is the GC cleaning up other things (what other things are there on the heap to really clean up?), is the freeMemory() method returning an approximation that's way off? Am I missing something or am I crazy?

    Read the article

  • PHPSecurityScanner & SpikePHPSecAudit - How do I?

    - by 01010011
    Hi, How do I run PHP Security Scanner and SpikePHPSecAudit? I've already extracted them at the root of my website and thought it could be run like phpSecInfo where you just navigate to www.mySite.com/phpsecinfo/index.php Any assistance will be appreciated. ps I am using Windows XP and XAMPP

    Read the article

  • C# Document Scanning

    - by ErocM
    I have a document storage application that I need to integrate with a scanner software or create one on my own. I have very limited funding so buying an expensive alternative isn't really an option. I thought about just linking to the customer's scanning software's executable and opening it when they want to scan but that just seems like a bad way of doing it. Anyone have any suggestions on how I do this? Thanks as usual, Eroc

    Read the article

  • Rails in production environment not working,but it's working in development environment

    - by user1834759
    An ActionView::Template::Error occurred in posts#index: couldn't find file 'jquery' (in /opt/ruby_apps/bookdate-website/app/assets/javascripts/cpanel_app.coffee:1) sprockets (2.1.3) lib/sprockets/context.rb:100:in `resolve' An ActionView::Template::Error occurred in topics#show: cannot load such file -- html/tokenizer actionpack (3.2.8) lib/action_controller/vendor/html-scanner/html/sanitizer.rb:18:in `tokenize' sometimes there is an exception thrown like the one mentioned above,but sometime it works why? my ruby environment is ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux] Rails 3.2.8

    Read the article

  • Ladder word-like game GUI problems

    - by sasquatch90
    Ok so I've written my own version of game which should look like this : http://img199.imageshack.us/img199/6859/lab9a.jpg but mine looks like that : http://img444.imageshack.us/img444/7671/98921674.jpg How can I fix this ? Is there a way to do the layout completely differently ? Here's the code : Main.java : import java.util.Scanner; import javax.swing.*; import java.awt.*; public class Main { public static void main(String[] args){ final JFrame f = new JFrame("Ladder Game"); Scanner sc = new Scanner(System.in); System.out.println("Creating game data..."); System.out.println("Height: "); while (!sc.hasNextInt()) { System.out.println("int, please!"); sc.next(); } final int height = sc.nextInt(); Grid[]game = new Grid[height]; for(int L = 0; L < height; L++){ Grid row = null; int i = L+1; String s; do { System.out.println("Length "+i+", please!"); s = sc.next(); } while (s.length() != i); Element[] line = new Element[s.length()]; Element single = null; String[] temp = null; String[] temp2 = new String[s.length()]; temp = s.split(""); for( int j = temp2.length; j>0; j--){ temp2[j-1] = temp[j]; } for (int k = 0 ; k < temp2.length ; k++) { if( k == 0 ){ single = new Element(temp2[k], 2); } else{ single = new Element(temp2[k], 1); } line[k] = single; } row = new Grid(line); game[L] = row; } //############################################ //THE GAME STARTS HERE //############################################ JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); panel.setBackground(Color.ORANGE); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); for(int i = 0; i < game.length; i++){ panel.add(game[i].create()); } f.setContentPane(panel); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); boolean end = false; boolean word = false; String tekst; while( !end ){ while( !word ){ tekst = JOptionPane.showInputDialog("Input word: "); for(int i = 0; i< game.length; i++){ if(game[i].equalLength(tekst)){ if(game[i].equalValue(tekst)){ word = true; for(int j = 0; j< game.length; j++){ game[i].repaint(); } } } } } word = false; for(int i = 0; i < game.length; i++){ if(game[i].solved()){ end = true; } else { end = false; } } } } } Grid.java import javax.swing.*; import java.awt.*; public class Grid extends JPanel{ private Element[]e; private Grid[]g; public Grid(){} public Grid( Element[]elements ){ e = new Element[elements.length]; for(int i=0; i< e.length; i++){ e[i] = elements[i]; } } public Grid(Grid[]grid){ g = new Grid[grid.length]; for(int i=0; i<g.length; i++){ g[i] = grid[i]; } Dimension d = new Dimension(600, 600); setMinimumSize(d); setPreferredSize(new Dimension(d)); setMaximumSize(d); } public JPanel create(){ JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); for(int j = 0; j < e.length; j++){ panel.add(e[j].paint()); } return panel; } @Override public void repaint(){ } public boolean equalLength(String s){ int len = s.length(); boolean equal = false; for(int j = 0; j < e.length; j++){ if(e.length == len){ equal = true; } } return equal; } public boolean equalValue(String s){ int len = s.length(); boolean equal = false; String[] temp = null; String[] temp2 = new String[len]; temp = s.split(""); for( int j = len; j>0; j--){ temp2[j-1] = temp[j]; } for(int j = 0; j < e.length; j++){ if( e[j].letter().equals(temp2[j]) ){ equal = true; } else { equal = false; } } if(equal){ for(int i = 0; i < e.length; i++){ e[i].changeState(3); } } return equal; } public boolean solved(){ boolean solved = false; for(int j = 0; j < e.length; j++){ if(e[j].getState() == 3){ solved = true; } else { solved = false; } } return solved; } @Override public String toString(){ return ""; } } Element.java import javax.swing.*; import java.awt.*; public class Element { final int INVISIBLE = 0; final int EMPTY = 1; final int FIRST_LETTER = 2; final int OTHER_LETTER = 3; private int state; private String letter; public Element(){ } //empty block public Element(int state){ this("", 0); } //filled block public Element(String s, int state){ this.state = state; this.letter = s; } public JButton paint(){ JButton button = null; if( state == EMPTY ){ button = new JButton(""); button.setBackground(Color.WHITE); } else if ( state == FIRST_LETTER ){ button = new JButton(letter); button.setBackground(Color.red); } else { button = new JButton(letter); button.setBackground(Color.yellow); } button.setSize(20,20); return button; } public void changeState(int s){ state = s; } public String letter(){ return letter; } public int getState(){ return state; } @Override public String toString(){ return "["+letter+"]"; } }

    Read the article

  • BufferedReader no longer buffering after a while?

    - by BobTurbo
    Sorry I can't post code but I have a bufferedreader with 50000000 bytes set as the buffer size. It works as you would expect for half an hour, the HDD light flashing every two minutes or so, reading in the big chunk of data, and then going quiet again as the CPU processes it. But after about half an hour (this is a very big file), the HDD starts thrashing as if it is reading one byte at a time. It is still in the same loop and I think I checked free ram to rule out swapping (heap size is default). Probably won't get any helpful answers, but worth a try. OK I have changed heap size to 768mb and still nothing. There is plenty of free memory and java.exe is only using about 300mb. Now I have profiled it and heap stays at about 200MB, well below what is available. CPU stays at 50%. Yet the HDD starts thrashing like crazy. I have.. no idea. I am going to rewrite the whole thing in c#, that is my solution. Here is the code (it is just a throw-away script, not pretty): BufferedReader s = null; HashMap<String, Integer> allWords = new HashMap<String, Integer>(); HashSet<String> pageWords = new HashSet<String>(); long[] pageCount = new long[78592]; long pages = 0; Scanner wordFile = new Scanner(new BufferedReader(new FileReader("allWords.txt"))); while (wordFile.hasNext()) { allWords.put(wordFile.next(), Integer.parseInt(wordFile.next())); } s = new BufferedReader(new FileReader("wikipedia/enwiki-latest-pages-articles.xml"), 50000000); StringBuilder words = new StringBuilder(); String nextLine = null; while ((nextLine = s.readLine()) != null) { if (a.matcher(nextLine).matches()) { continue; } else if (b.matcher(nextLine).matches()) { continue; } else if (c.matcher(nextLine).matches()) { continue; } else if (d.matcher(nextLine).matches()) { nextLine = s.readLine(); if (e.matcher(nextLine).matches()) { if (f.matcher(s.readLine()).matches()) { pageWords.addAll(Arrays.asList(words.toString().toLowerCase().split("[^a-zA-Z]"))); words.setLength(0); pages++; for (String word : pageWords) { if (allWords.containsKey(word)) { pageCount[allWords.get(word)]++; } else if (!word.isEmpty() && allWords.containsKey(word.substring(0, word.length() - 1))) { pageCount[allWords.get(word.substring(0, word.length() - 1))]++; } } pageWords.clear(); } } } else if (g.matcher(nextLine).matches()) { continue; } words.append(nextLine); words.append(" "); }

    Read the article

  • Reading three words and sorting them in lexicographic order

    - by Derrick
    I am trying to create a program that asks the User to type three words and sort them in lexicographic order. EXAMPLE; Enter three words separated by spaces: Pear Orange Apple Apple Orange Pear The program is working fine (if I attempt the above example) except for one type of combination example that I will show below. EXAMPLE; Enter three words separated by spaces: Orange Apple Pear Apple Pear Pear The program is skipping the first word (Orange) if it is supposed to appear in the middle of the three words. I believe that this line of code is affecting the program because it says that "this assigned value is never used" but I'm not sure how to fix it since I'm still an entry Java learner. middle = firstWord; Because of that line being unused, it's why Pear appeared twice. import java.util.*; public static void main(String[] args) { Scanner wordInput = new Scanner(System.in); String firstWord; String secondWord; String thirdWord; System.out.println("Enter three words separated by spaces: "); firstWord = wordInput.next(); secondWord = wordInput.next(); thirdWord = wordInput.next(); String top = firstWord; String bottom = firstWord; if( top.compareTo(secondWord) > 0) { top = secondWord; } if( top.compareTo(thirdWord) > 0) { top = thirdWord; } if( bottom.compareTo(secondWord) < 0) { bottom = secondWord; } if( bottom.compareTo(thirdWord) < 0) { bottom = thirdWord; } String middle; if( !firstWord.equals(bottom) && !firstWord.equals(top) ) { middle = firstWord; } if( !secondWord.equals(bottom) && !secondWord.equals(top) ) { middle = secondWord; } else { middle = thirdWord; } System.out.println( top ); System.out.println( middle ); System.out.println( bottom ); } } Does anyone what I am missing or doing wrong? :( Please and thank you for any help!

    Read the article

  • Random generates same number in java

    - by user1613360
    This is my java code. import java.io.*; import java.util.*; import java.util.concurrent.TimeUnit; class search { private int numelem; private int[] input=new int[100]; public void setNumofelem() { System.out.println("Enter the total numebr of elements"); Scanner yz=new Scanner(System.in); numelem=yz.nextInt(); } public void randomnumber() throws Exception { int max=500,min=1,n=numelem; Random rand = new Random(); for (int j=0;j < n;j++) { input[j]=rand.nextInt(max)+1; } } public void printinput() { int b=numelem,t=0; while(true) if(b!=0) { System.out.print(" "+input[t]); b--; t++; } else break; } } public class mycode { public static void main(String args[]) throws Exception { search a=new search(); a.setNumofelem(); a.randomnumber(); a.printinput(); } } Now the function randomnumber() just returns the same number.The function executes perfectly if I execute it as a separate java program but fails miserably if I call it using an object.I have also tried the following variations but nothing works everything return the same number. Variation 1: public void randomnumber() throws Exception { int max=500,min=1,n=numelem; Random rand = new Random(); for (int j=0;j < n;j++) { TimeUnit.SECONDS.sleep(1); input[j]=rand.nextInt(max)+1; } } Variation 2: public void randomnumber() throws Exception { int max=500,min=1,n=numelem; Random rand = new Random(); for (int j=0;j < n;j++) { rand.setSeed(System.nanoTime()); input[j]=rand.nextInt(max)+1; } } Variation 3: public void randomnumber() throws Exception { int max=500,min=1,n=numelem; Random rand = new Random(); for (int j=0;j < n;j++) { TimeUnit.SECONDS.sleep(1); rand.setSeed(System.nanoTime()); input[j]=rand.nextInt(max)+1; } } Sample input/Output: Enter the number of elements: 5 23 23 23 23 23 23

    Read the article

< Previous Page | 21 22 23 24 25 26 27 28 29 30 31 32  | Next Page >