dantinkakkar 19 Junior Poster

You're right there... But since I've newly migrated to Linux, I seriously find Windows damn easier to hack into, if you can understand what I mean; I'm new with Linux, may take me some time to get used to it. I've been a Windows user for lifelong and now this! :D

dantinkakkar 19 Junior Poster

There is a way of nullifying that effect. Inside the body tags, create a <div> at the top level and place all of your content inside it. That makes the inner elements easily positionable and they stay where they are. For example, look at the forums! Try zooming in and out and the top-level <div> will shrink and grow without disturbing the layout. I hope you can understand this concept now. I'll write a snippet about it later today, because I'm a little busy at the moment.

dantinkakkar 19 Junior Poster

Add it to the Google listings, put it next to your name. If you have a Twitter/FB account, promote it there. If you can spare a few bucks, give out sponsored results on Google. There's a lot you can do.

dantinkakkar 19 Junior Poster

Joomla was voted as the best CMS over the other last year by a panel of web developers in the so-and-so conference, and you can use it because it's very easy to set it up and go about it - more than th others, except WordPress maybe, but that's for blogs, articles, and similar stuff.

dantinkakkar 19 Junior Poster

Surf around the net... Google is your best friend, and remember that some websites out there will provide you images as Freeware.

dantinkakkar 19 Junior Poster

Well, I guess he's asking for your opinion rather than choices. It depends upon several factors; for instance if you're developing software that does not interact much with the hardware and stays at the software level [if you understand me]; you might find Java easy-to-learn and powerful too. If you're gonna go around interacting with the hardware, then I would recommend C. It is the lingua franca of programming.

dantinkakkar 19 Junior Poster

Whoa. There's a solved count? I'm going around telling people to mark their threads as solved so that they get added to the knowledge base and can help others, too. Seriously. :O

dantinkakkar 19 Junior Poster

The correct answer is, as you say, 88. The problem - I have recognized it. It's not that we're doing anything wrong with the code. 895430243255237372246531, which is the value of 11^23, is too large a number even for long. :)

It is not computed properly by the compiler. The number is just too big.

dantinkakkar 19 Junior Poster

In my opinion, you should find this code self-explanatory.

[EDIT: This is not a spoiler, just another way of doing it. Do it yourself once to get the hang of it.]

Oh, plus this code does not handle decimal points. If you want to tackle decimal points too, just split the string into two portions, one half being the left and one half being the right side. Then make the left half go through this procedure and print a dot and the right half as it is.

import java.io.BufferedReader;
import java.io.InputStreamReader;
//..............
try
{
   String rcb = new BufferedReader(new InputStreamReader(System.in)).readLine();
   if(rcb.length()>3)
   {
      char abc[] = rcb.toCharArray();
      for(int i=abc.length;i>2;i-=2)
      {
         System.out.print(abc[i] + ",");
      }
   }
}
catch(IOException e){e.printStackTrace();}
dantinkakkar 19 Junior Poster

@weekendrockstar is right. You can use CSS to do that... It'll make it damn easier... If you don't want anything to move around then I suggest to you to use absolute positioning. Since your content is already inside a <div>, it ain't gonna get affected! :)

dantinkakkar 19 Junior Poster

you can't accept only the two first char, since you have to print out the original first.

try extracting the first two characters with the substring method of String, set it to lowercase, and then you can perform equalsIgnoreCase

That's what I meant, by trimming the first two chars.

Isn't it possible, though? If you're using a BufferedReader to read the String char-by-char, you can stop at two chars by limiting the loop, can't you? You don't need to use readLine() for that!

dantinkakkar 19 Junior Poster

Are you sure about that? You don't need to use the "top" attribute of absolute positioning to position it around. You may even use the "bottom" attribute, and that way, it will remain cross-browser compatible, too. If you're talking about cross-browser compatibility, there are many ways to achieve it, and I'm thinking of doing a snippet myself... I'll PM the link to you after writing it. For now, though, use the bottom attribute and you'll find that absolute positioning will work! :)

dantinkakkar 19 Junior Poster

Back to the topic you get 65 if you write the exponent code yourself, instead of using Math.pow(int,int). @adil_bashir, are you sure it's 11^23 and not 23^11? o.O

dantinkakkar 19 Junior Poster

(Am not editing since this is an explanation and you may miss out on it if I edit.)

The query

SELECT LAST(Emp_id) FROM empDetail

Will return the last value of Emp_id, or the last employees' number, say 100.
Now, I've taken it in a string as follows:

String res = rs.getString(1)

No loops 'coz the output will bein the form of a lone String only. Now, parse the integer out of it.

int hh = Integer.parseInt(res);
hh+=1;

Added it by one and now append it to the TBox.

txtEmpNo.setText(hh.toString());
dantinkakkar 19 Junior Poster

Wait. You got something wrong with your code there.

clearFields();
String sql = "SELECT LAST(Emp_ID) FROM empDetail";
openDatabase();
try{
ResultSet rs = stmt.executeQuery(sql);
String res = rs.getString(1);
int hh = Integer.parseInt(res);
hh+=1;
}
catch(SQLException e){}

I've modified line 2. Look at that first. Now, look at the rest. hh is your final result which you need.

dantinkakkar 19 Junior Poster

It's nothing. Just do me a favour, and mark this thread as solved! :)

dantinkakkar 19 Junior Poster

You'll have to play around with the SQL Query. This is the query you might need:

SELECT LAST(column_name) FROM table_name

Execute this, and the employee number of the last record will be returned as the output.

You are familiar with executing SQL queries, I hope? If you're not, the here's how you can go about:

QueryString = "SELECT * from user_master1";
  rs = statement.executeQuery(QueryString);
  while (rs.next()) {
  System.out.println(rs.getInt(1) + " " + rs.getString(2) + "  
                  " + rs.getString(3) + "  "+rs.getString(4)+"\n");

[EDIT: In your case, only one value will be returned, so I don't think you'll need the loop. :) ]

dantinkakkar 19 Junior Poster

No, that isn't a viable solution. @ForceStr you may want to consider using the SwingWorker thread, it's for this use!

http://java.sun.com/products/jfc/tsc/articles/threads/threads2.html

They've even added a Progress Bar example! :)

dantinkakkar 19 Junior Poster

Mark it as solved, please. :)

dantinkakkar 19 Junior Poster

Try giving SCDGHFHFDHD as the input. If it works fine, then there's a problem when SCdgfgd is converted to lowercase. If there's a problem in that, then you should -

A. Either trim the String and check with .equalsIgnoreCase()
B. Convert it selectively after performing .toCharArray() on it.

I'd suggest "A" since "B" would be too long. Just trim the String or input to accept only the first two characters and check them with .equalsIgnoreCase(). :)

dantinkakkar 19 Junior Poster

When "New" is clicked, the question wants you to create a new employee entry. The employee number will be one higher than the existing number of employees present obviously. So what I suggest is that you get from the DB [unless you've already stored it somewhere] the employee no. of the last employee, add it by one, and set the value for the employee number textbox field. Just reply if you have a problem with writing the code and I'll help you out there, too! :)

dantinkakkar 19 Junior Poster

As @zeroliken said, there was no need for the choiceA, choiceB, choiceC, and choiceD variables. Other than what he said, I don't see anything wrong with your code. You should run it once and check it out! :)

dantinkakkar 19 Junior Poster
dantinkakkar 19 Junior Poster

Tried installing wireshark? (on my system... I had to go thru hell)

dantinkakkar 19 Junior Poster
import java.io.*;
import java.net.*;
import java.util.*;
import static java.lang.System.out;

public class ListNets 
{
    public static void main(String args[]) throws SocketException {
        Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
        for (NetworkInterface netint : Collections.list(nets))
            displayInterfaceInformation(netint);
    }

    static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
        out.printf("Display name: %s\n", netint.getDisplayName());
        out.printf("Name: %s\n", netint.getName());
        Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
        for (InetAddress inetAddress : Collections.list(inetAddresses)) {
            out.printf("InetAddress: %s\n", inetAddress);
        }
        out.printf("\n");
     }
}

This displays the network interfaces available, and I'm somewhat sure that that's the thing being monitored. The code works perfectly, but how do I monitor them -- back to square one!?

dantinkakkar 19 Junior Poster

The problem is, that I want to read data and analyze it from a promiscuous network device programmatically using java. Using existing software like WireShark/DarkStat is NOT a solution. I wanna do it myself. Any hints on where do I start?

dantinkakkar 19 Junior Poster

You might want to try out CSS3 transitions...
http://www.w3schools.com/css3/css3_transitions.asp

dantinkakkar 19 Junior Poster

If you want to place a comment box on your website, JSP will be more than enough keeping in mind that you've to store all of the comments for future use.

dantinkakkar 19 Junior Poster

CSS is better anyday, since it is more flexible than tables. CSS has been designed to replace tables as a layout system and you can adjust your data more precisely and with lesser difficulty than you can do with tables. Imagine creating table cells of varying heights and widths all over a page in contrast to simply specifying it's location in terms of a few attributes. Hope you get my point! :)

dantinkakkar 19 Junior Poster

What your problem is that you're using relative positioning, so if one element disappears or reduces in size, the other layout is disturbed. This is a very common problem faced by web developers. What you should try to do is use absolute positioning in combination with stacking of elements using the z-index property. That should work! And it won't disturb your layout if the other elements are adjusted.

Cheers! :)

dantinkakkar 19 Junior Poster

Alright, so I tried to write a little short guide on Object Input and Output to files, since the worst situation one can find themselves is being unable to serialize files in a proper and readable format. One way to do so is to create an object of a class containing variables you need and then serialize it. The Java Library provides two functions, namely readObject() and writeObject() for the following purpose. Now, let us assume that I want to create a library-sort-of-system, where I want to save the book's name and author, and then I want to store the names of all of the books in a serialized [not the Java-term, the other orthodox term] manner, starting from 0 to n, I would have used a database. But since I'm explaining a file-based concept here, I'll use files; what I want to say is that a library management system is not a practical use and is only an example.

So, I have a table of this sort which I want to serialize...

BOOK_S.NO | BOOK AUTHOR | BOOK NAME
1 | Someone1 | Somename1
2 | Someone2 | Somename2

In a file-based system, we may define a class, say Booklist and then serialize it. Booklist may look like this:-

public class booklist
{
java.util.List book_auths = new java.util.ArrayList();
java.util.List book_names = new java.util.ArrayList();
/*Def. of an arraylist http://docs.oracle.com/javase/1.4.2/docs/api/java/util/ArrayList.html*/
}

io-trav.gifOther Notes 1. The readObject() and writeObject() methods have to be called from …

dantinkakkar 19 Junior Poster

Please explain in a more lucid tone. And if you have another problem, @nandosss, start a new thread.

dantinkakkar 19 Junior Poster

OK thanx. But isn't there any way to share data between java and python using Object input and output streams?

You can't share a Java object with a Python file, because it won't be able to decipher it. You may want to look inside the readObject() code and try implementing it in Python.

dantinkakkar 19 Junior Poster

Total java lines

".length" will give you the length in characters, and not lines. So if you want to read the number of lines, I guess you'll have to open the files one-by-one and increase the counter for each file by 1 each time you encounter a semicolon.

Hope this helps! :)

dantinkakkar 19 Junior Poster

Now you make a valid point. :)

dantinkakkar 19 Junior Poster

You can do something like this:-

public class sera
{
List ofNames = new ArrayList(); //assume that I've imported all necessary pkgs
List ofNumbers = new ArrayList();
}
//..............
void whatever()
{
sera xyz = new sera();
//take in the values and fill in xyz
//serialize xyz
}
//this is it, now?

What I wanna show is that the whole object is being serialized as a whole. I've pasted a link to The Java Tutorials on this. This way, when you read it, you get the lists of all the people in one go in a variable during execution and you can manip. it.

dantinkakkar 19 Junior Poster

well, yes, but how are you trying to do so? unless he has a maximum length for his elements ...
sure, he can say:
number name, at which point he just needs to read the line, first String is the number, convert to number, rest of the line is the name, but what if he needs more information?
according to his code, he has (at least) a first and last name. since there are names (both first and last) that contain more than one part (separated by a space), you can't just check String by String. since you can't just say: a name can not be longer than ... unless you accept the risk that certain valid and existing names will not be able to be used in your application, you also can't use a max length, unless you make this length way too long for most of the names, so I think going with a separator char is about the best way.

No, you're not getting me. I'll just post some code, wait.

dantinkakkar 19 Junior Poster

ChatBot Client:

The client application will manage the chat between the end-used and the chatbot. The client is responsible for retrieving the end-user’s comment, passing it to the chatbot, and retrieving and displaying the chatbot’s response. The user’s or chatbot’s name should be used as the input prompt. Below is a sample run of the client:

Enter your name: Trish

Hi! My name is Mutebot

Trish > hello

mutebot > I'm just learning to talk

Like This :)

I want my code to show like that.

What I've understood by this is that you want your chatbot to send messages triggered by certain phrases... such as "hi" or "hello" or something like that. Am I going right?

dantinkakkar 19 Junior Poster

what do you mean by this?
he already chose to use '.txt'
I assume he'll be reading it through the application he's writing. a simple separator char will do the trick there.

You interpreted me wrong. I wasn't talking about the file extension. I was talking about arranging the data in a certain way inside the file.

And yes, a char separator will do, but the code'll be simpler if he tries the object input-output way. It's not complicated at all. (Not that your way's complicated, but I'm just saying)

dantinkakkar 19 Junior Poster

http://www.daniweb.com/software-development/java/code/408638

Yes, this one's quite useful. Just go through it and try to understand the logic behind the code. As for printing to files is concerned, just adopt a specific file format and save as per it keeping in mind that you have to read it later. You may want to create a separate Java class specially formatted for storing your kind of data and save the class object as a whole. Try using lists and synchronize them all together.

For example...

public class nameofclass
{
List names;
List numbers;
//etc.
}

You'll have to initialize the list by suffixing

= new ArrayList();

You can find all of this under java.util

Save the class object WITH the lists as a whole to the file. Since you know the contents of the class, you can easily read it back using object-f-input and output.

http://docs.oracle.com/javase/tutorial/essential/io/objectstreams.html is a good tutorial on reading and writing objects to files.

Also, read through the whole trail if you're new to the concept of file input and output, and best of luck. :)

dantinkakkar 19 Junior Poster

Yeah, he's right. Another version of my code got 65 as output. I guess that's what's dwindling your answer... :\

If you try writing a piece of code to find out the exponent of a number, and you try solving 11^23, you get 6839173302027254275.Then, if you try finding out it's remainder with 187, you get 65, which is wrong, I guess, as per you.

dantinkakkar 19 Junior Poster

Funnily...

public class test {
    public static void main(String[] args)
    {
        long hyz = (long) Math.pow(11.0, 23.0);
        hyz = hyz%187;
        System.out.println(hyz);
    }
}

Output = 161?

Also, I edited your code a bit and checked...

int c = 11;
    int d = 23;
    int n = 187;
    long dt;
    dt = (long)((Math.pow(c,d)));
    long rc = dt%n;
    System.out.println(rc);

I put the modulus n part in another line... and whoa! 161

So, you want this, right? (11^23)%187?

dantinkakkar 19 Junior Poster

Your code was working save for some characters, right?

[edit: forget the quote. I just clicked reply :)]

dantinkakkar 19 Junior Poster

Welcome :)

dantinkakkar 19 Junior Poster

sudo apt-get install ... or sudo dpkg -i ... is pain and next next next next next finish is simple?

Sometimes... That is not enough! :P :D Nuff said :) ;)

dantinkakkar 19 Junior Poster

A direction you might look in is your network card's scandalously-named promiscuous mode.

Ya, I guess you got it right there, but will Java be enough for accessing it? Like, CAN I do it in Java? How I'll do it is a separate journey altogether :D but can I do it?

dantinkakkar 19 Junior Poster

Hmm another method to the above, may be having the client send its messages along with a few parameters such as the user to who its too, you'd separate the two, search through the arrays which have each client that's connected -most importantly the open socket connection to the client and the username to identify the client- and find that clients unique name, or number or whatever, but as suggested rather do not use IP's... The server will then send the data to the appropriate client socket that the username was matched too...Thats what i did in mine.

[edit]However maybe it would be easier too have a client that has a server socket too and listens for connections? and thus recieves messages, you'd get the list of clients available and their IP/ports from the server. Guess there's many ways to skin a cat :P

Yeah... That's what. A simple system that just sends and receives input is not gonna work in this context. He needs to add a lot of things to it!

dantinkakkar 19 Junior Poster

If it has been solved then please MARK it as solved. Thanks! :)

dantinkakkar 19 Junior Poster

primary layer

These two words are of importance. Google for "accessing keys of the second layer using java"

dantinkakkar 19 Junior Poster

There may be some problem with the encoding... Just check the documentation once