llaspina 19 Light Poster Team Colleague

To say that an aglorithm works means that we tested it on some input values and verified that it gives us the right answer.
What input did you check the math with? How many kids were you assuming?

From my earlier post:

To prove toourselves that we really understand the task, let's say we have a family of 5: mother, father, and three kids. The father make $1500 per week. How much money pocket money does the wife and each kid get?

So, let's walk through this example with your code:

//salary input 1500.
salary = (salary/2);  //now salary is 750, half went to house.
salary = (salary *1/3); //now salary is 250. This is how much we are saving.
salary = (salary *1/3); Now salary is 83.3333 Why?
salary = (salary *1/2);  Now salary is 41.67. No, wrong answer.
System.out.println("Pocket money obtain by one parent: " + salary);

Now, lets forget the code, like I suggested, and do the problem.
The whole salary is 1500.
Half goes to the housr, so 750 is left.
One third gets saved, so 750 - 250 = 500 remains to dived as spending money.
At this point we realize that you were not dividing up the problem correctly. The first part of the problem is to determine how much spending money is left for the whole family. We just did that part now and you never did that in your program.
Now, how …

llaspina 19 Light Poster Team Colleague

This is really not a Java question. It is an algebra question, and we are being asked to represent the answer with Java code.

I recommend we start by forgetting about Java and just try to understand the question. If we can't solve it, how can we teach the computer to solve it?

We are being asked to:

Write a program that allows you to input the salary of a person and the number of children he has and output the pocket money obtained by one of the parents and one child.

To prove toourselves that we really understand the task, let's say we have a family of 5: mother, father, and three kids. The father make $1500 per week. How much money pocket money does the wife and each kid get?
If we can answer that, then try to abstract it:

  • What if the father makes $1600 instead?
  • What if the father makes $1200?
  • What if the father makes x dollars per week? Can we express the answers in terms of x?

Once we are able to express the answer in terms of x, we are close to being able to write a program to do this calculation for us. Of course, the number of children also needs to be a variable.

~s.o.s~ commented: "If we can't solve it, how can we teach the computer to solve it?" - Brilliant +15
llaspina 19 Light Poster Team Colleague

Just to illustrate Hiroshe's point, I received an email from a recruiter looking to hire a developer for an application in the medical field in New York. I also teach programming and wasn't looking to change jobs, but I was curious, so I responded. (I was also wondering why they contacted me since I don't think I enough experience for the job). The recruiter asked me about the languages and technologies I've used and then informed me that they need someone to work with Ruby on Rails. Even though I have never used Ruby, they were willing to bring me in for an interview if I was open to learning it. Not only do I not have a degree in computer science, I don't even have the skill set they are looking for and they still wanted to interview me.

Since I teach computer science and math to high school students, I can relate to the boredom, especially if students are not very interested or motivated. If you can find some projects to do with your best students that will help you develop your own skills and you won't be bored. It may also better prepare you for a transition into the industry.

If I have a strong class, I may be able to have students work together to build something interesting (using techniques or technologies new to me) and if I don't have a strong class, then I still may have one or two talented and motivated students willing …

llaspina 19 Light Poster Team Colleague

One option is to store each row as an element in a list. For instance, say the table stores Pets. Create a Java object called Pet which has data fields matching the columns in the table. This is basic the concept behind ORM (object relational matching).
Then you could do something like this:

ArrayList<Pet> petList = bew ArrayList<>();
while(rs.next() ) {
  int id = rs.getInt(0);
  String name = rs.getString(1);
  String breed = rs.getString(2);
  petList.add(new Pet(id,name,breed) );
}
llaspina 19 Light Poster Team Colleague

You need to store the Staff object as you search for it. An easier way to do this is with an enhanced for loop which uses Iterators for you, but they are hidden.

    Staff displayMe = null;
    boolean found = false;
    for (Staff s : staffList) {
        if(s.getIdNo().equalsIgnoreCase(Search1)) {        
           found  = true;
           displayMe = s;
         }
     }
     //now you have the Staff object you want to display if found.
     //just for testing purposes, start with this:
     System.out.println(displayMe);
llaspina 19 Light Poster Team Colleague

I'm not sure what you are looking for with ANT and the command line. What is your goal? What are you trying to accomplish?

I use ANT for a few minor things, like uploading files via FTP, signing jar files, and copying some files from the build directory to another place for deployment. I put these tasks together with ANT so that afer building my application, I can quickly sign my application and then upload it to the site my customers run it from using JNLP. I never bothered editing build.xml; that's why I use an IDE. So netbeans uses ANT to handle the build process and I use netbeans so I can focus on writing my program. If you want to play with ANT, the Apache reference might be a good place to start.

You can run a java program from the command line with the commmand java [program name] followed by any parameters you want to pass to the main method. Your IDE (Eclipse for you, Netbeans for me) runs this command for you and you can configure any command line parameters in the run properties. Are you trying to create a command line (console application) of some kind?

llaspina 19 Light Poster Team Colleague

As part of a First Robotics project (FRC) I placed a live video feed from a web cam mounted to a servo inside of a swing application (without recording the video). This was done using the SmartDashboard. It's all open source, so you might be able to grab the code and find what you need.

I have never done video capture, but it's supported in JavaFX 8; you can watch a video here. Jump to minute 39 to see video capture.

For learning JavaFX, I found the Oracle tutorials helpful.
I also read a few chapter of Pro Java FX 2, which I managed to get my local library to purchase.

jalpesh_007 commented: nice answer. +4
llaspina 19 Light Poster Team Colleague

If this is from a summer college class, then the problem may be that the material was presented more quickly than it could be learned. I have found that CS instruction is very poor at some colleges and this project makes me curious: What was the actual assignment? Was this the first assignment?

There are three simple steps to follow when you are building something:
1. Decide what you want to build.
2. Build it.
3. Now make sure you built it correctly. (test it to verify that it meets the requirements)

People often ignore step 1 or 3. Whether building software for a client or completing a school assignment, the first step is to understand EXACTLY what you need to create. Maybe all that is required is just a mock SMS donation system that demonstrates the concept of moving virtual money from one virtual phone number to some virtual charity. That would not be an impossible project after a semester of work.

llaspina 19 Light Poster Team Colleague

THe suggestion to disable Java in the browser and better yet uninstall it is just silly. When security holes are disovered in Windows, do we suggest that all users uninstall Windows? Java powers a large number of businesses and many users need Java installed to get their work done. Although Java is not very popular in the browser, when it is used in modern web apps there is often no way of using the application without using the Java applet. For instance, two of the most popular gradebook / Student management systems run over java applets or JWS. Most high schools on Long Island use one of these systems, so the suggestion to uninstall Java is certainly not being followed in schools.

Hopefully any remaining vulnerabilities will be fixed very soon, but we may have to wait until February for a more complete solution fom Oracle.

Does anyone know of an actual exploitation (virus, DDOS attack, stealing confidential data) being executed? Or is it just proof-of-concept code that was run?