JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

No. If you want to test for numbers being in particular ranges you need if/elseif/else. Switch only works for specific values, not for ranges.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

At last!
You have a switch with cases for 1,2,3,4 and 5. You enter 70, which is not 1,2,3,4 or 5, so it executes the default. That's how switch is supposed to work.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

From the very first post it was clear that score was a number up to at least 49, so I suspected the value being used was > 5.
But since gh.fuz has continued to deliberately ignore or deflect our requests to reveal what value was bing printed, I can only conclude that either he is deliberatly having fun at our expense, or is incapable of understanding and following the simplest of requests.
Either way, I give up. Good luck Hans

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, one last chance. You have been asked repeatedly what value for score is printed when you run the program. You have ignored those requests. What does it print?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I think gh.fuz is just having fun with us. Anyway, joke over as far as I'm concerned. Bye. J.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes you already said that. Repeating it is just a waste of time.
Printing "INVALID" implies that the value you are switching on is not 1, 2, 3, 4, or 5.
Maybe when you execute the score = keyboard.nextInt(); you are not getting the value you expect.
That's why I asked you to print the value of the score variable.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

NO! I meant print the value of the variable score so you can confirm that it is 1, 2, 3, 4, or 5

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

On line 12 try printing the value of score, maybe that will clarify what's happening

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's odd, but never mind - I'll mark it for you.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Its the pale blue button "Mark Question Solved" just below the entry field for submitting a reply, which is just below this message.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, but of course components calulate their preferred size using the metrics of their current font etc, so they scale properly with different environments.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Most components calculate a preferred size based on their contents, eg the text in a JLabel or the overall size of the children of a JPanel. Most layout managers use getPreferredSize rather than getSize. The layout manager will then often override that to make the components fit according to its own rules (eg all the components in a Grid are the same size). On average you are more likely to influence the layout manager by setting a minimum size.
If mKorbel is around he's a real expert on this stuff...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's pixels

If you are using a layout manager like you should, then setSize is pretty much useless. With a null layout manager it sets the component size in pixels, and you look really silly when someone runs it on a retina display.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's all wrong! import just affects the way that names are resolved at compile time. It has absolutely zero effect on what classes get jarred, or on the run time.
importing everything is a lot easier than importing just the classes you need, especially if you are not using an IDE that adds imports for you. It's possible that it may slow compilation slightly,but no so much thatyou would notice.
The danger in doing it is that some names are used in multiple packages, eg there'a List in java.util and another List in java.awt, and you may get incredibly confusing error messages, eg try...

import java.awt.*;
import java.util.ArrayList;
...
List<String> x = new Arraylist<>();
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's in the API documentation, which should be open on your desktop all the time you are writing anything in Java. It's your absolutly essential reference doc.
http://docs.oracle.com/javase/7/docs/api/

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK, in that case, after another look I can see the problem. Check the API documentation for Scanner, you have mis-spelled the name of the method.
Next time please post (copy/paste) the complete text of your error message(s) - that would have enabled me to identify the fault immediately.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Tables are split into two main parts - the visible GUI stuff, and the data for the table. This allows you to chose how to store the data any way you like, without affecting the way the GUI display works (and vice-versa). The part that holds the data is called the TableModel.
For simple cases, where there's nothing special about the data storage, you use a DefaultTableModel that does it for you, so you don't have to write any extra code. Similarly, the GUI part of the table has methods to access the data in the TableModel for you, so you don't need to bother with that either unless you have a special requirement.

Oracle's tutorials are an excellent source of info. Maybe not the easiest because they are so comprehensive, but an ideal place to go when a simpler tutorial hasn't answered all your questions, eg
http://docs.oracle.com/javase/tutorial/uiswing/components/table.html

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

If you are using Serialization (ie write/readObject) then bean standards are irrelevant, but you must declare every class involved as "implements Serializable" as a way of asserting that your classes don't contain anything the can't be serialized - eg references to live operating system handles.
If you are using javabeans XML serialization then you must conform to java beans standards, and the Serialization marker interface is irrelevant.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Literal \ characters in Java Strings need to be "escaped" - ie replaced with a double \
You did that in the findInLine, but not in your useDelimiter

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I'm not sure how it will interpret that classpath. Try specifying a complete explicit path to the jar file.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, i n that case the jar should contain a folder A with the class file in that, and the classpath should include the jar file.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The package A has to be in a place that's in your classpath. If you have C:\Z\A\B\A\Print.class then A.Print is in C:\Z\A\B, so that's what has to be in the classpath.

Ps: Having two directories called A, one inside the other is perfectly legal, but pretty much guaranteed to cause confusion and mistakes.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Yes, I think it should be a semicolon as well

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Why is there a colon in the middle of theclasspath - is that legal?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The3 Java Language Spec documents all this stuff definitively. For throw it says

14.18 The throw Statement
...
A throw statement causes an exception (§11) to be thrown
...
ThrowStatement: throw Expression ;
The Expression in a throw statement must denote either 1) a variable or value of
a reference type which is assignable (§5.2) to the type Throwable, ...

(plus a load of stuff about what happens if ot goes wrong)

So there's really not a lot to say in answer to your question. The only way to write it is "throw" followed by something that is or extends Throwable (eg an Exception).

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Apart from storing some of the results that are used repeatedly (eg Math.pow(b, 2) etc) I can't see any obvious improvements.
If the next exercise is to do the same thing with a different equation, then that would suggest writing a generalised expression parser, from which printing the intermediate reuslts would be easy.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

But how does Java interpret the equation? Does it do proper BEDMAS

Yes

Java Language Spec:

15.7.3 Evaluation Respects Parentheses and Precedence
The Java programming language respects the order of evaluation indicated
explicitly by parentheses and implicitly by operator precedence.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

5: which requirements did he fail?
6. did he fail both?

One way would be to have a couple of booleans,one for each condition, showing whether that condition was met or not. You already have if tests for those conditions, so you have all the code you need to set the booleans.
You can then use them to control some print statements: eg (pseudo code)

if (metCondition1) print "you passed criterion 1"
else  print "you failed criterion 1"
   or 
if (didn't meet both) print "you must repeat"
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's the output I would expect from line 13/14.
Did you enter 3 values for examscore, assessment, fees? Followed by a carriage return?

It's clearer for everybody if you prompt for one value at a time, eg (pseudo code)

print "what is the exam score" // NB print, not println
examscore = ...nextInt...
print "what is the assessment?
assessment = ...nextInt...
print "what are the fees> ?
fees = ...nextInt...
etc
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

One step at a a time...
It's a bad idea to try to code the whole application before you start testing. Experienced programmers try to code in small pieces, compiling and testing as they go. That way it's easier to understand amd fix your errors.
You have enough code there to be able to compile, run, and test. Get that working before worrying about stages 5 asnd 6.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You just copy/pasted your assignment without even a moment taken to explain what help you need. That's highly disrepestectful to the many people who give their time to help others here.

There are lots of people here who will freely give their time to help you become the best Java programmer you can be. There's nobody here who is interested in helping you cheat or doing your homework for you.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

OK.
Each row represents one student, with various data ablout that student. So the obvious thing to do is to define a Student class with sNo, name, department, and marks as instance variables. You can create a Student instance from each row of the data, and put those in an array(or some kind of List). You can then sort the Students according to whatever criteria, or simply loop through them to find the one with the highest marks etc.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

What do you mean by "compare"? Are you looking for duplicates, trying to sort the rows, or what?

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

IMHO those GUI libraries are way too advanced for this requirement. There's nothing there that requires anything more that just an ordinary Swing GUI.
The Oracle tutorials are unbeatable for accuracy, currency, and completness, but you may want to Google for some simpler tutorials if the Oracke ones are too much
http://docs.oracle.com/javase/tutorial/uiswing/index.html

অসীম commented: I tried to play with swing before by writing codes.Now I tried again from your link and it seems easier than before. I think I can start now, I'll mark this thread solved and thanks to both of you +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

I don't know why this is in the Java section, but...
TextPad 5 is commercial software so either:
a) You have purchased a licence, in which case you should upgrade to the current version (7.1), then, if the problem is still there, get on to their tech support to fix it.
or
b) You are using it but haven't purchased it, in which case you're violating DaniWebs T&Cs by asking for help with it. Your best option in that case is to remove it from your computer and install a legal free editor such as the excellent and highly recommended notepad++

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Hello Wilfred, welcome to DaniWeb.

We don't do people's homework for them.
If you have a specific problem with some aspect of Java then we're glad to help, but simply copy/pasting your assignment and waiting for an answer is just insulting.

DaniWeb Member Rules (which you agreed to when you signed up) include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

Post what you have done so far and someone will help you from there.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's a good start - you are adding lots of labels, each with an image in it.
Now on the the second part of my previous post. You need to set a GridLayout for your window so those labels get layed out in a grid. Read the tutorial link I gave you.

stultuske commented: to compensate for unappreciated help +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Why?
You had code to read one image - why did you change that.
Did you read my previous post (first sentance)? It told you exactly what to do.

stultuske commented: to compensate for unappreciated help +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You have a break; as the last statement in your loop, so it will always exit the loop at the end of its first pass. Maybe you intended that to be inside the else block?
Also: the if test on line 28 is redundant.

stultuske commented: I missed that one ... +0
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

That's a classic error!
On line 24 you declare a text field t1
In your test method you have
JTextField t1=new JTextField("");
That creates a new variable t1, "masking" the original one, and initialises it.
When test finishes executing, that t1 goes out of scope, and the associated text field can be garbage collected.
The rest of the code then tries to use the original t1, but that has not been initalised, so it's still null.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Could it be that the action command is "Save" (defaults to the same as the button text), but you are testing for equals("save") ?

stultuske commented: equalsIgnoreCase to the rescue :) +13
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The code that puts the image into a label (lines 20-24) can go inside the while loop so you create one label for each image in the result set.

If you set a GridLayout layoput manager for your window then the labels that you add will be placed ina grid with whatever number of rows and columns you specified.
THis tutorial explains - it looks complex but you only need the very simplest part - so that's easy:
http://docs.oracle.com/javase/tutorial/uiswing/layout/grid.html

stultuske commented: to compensate for unappreciated help +13
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

You're missing a set of brackets round the whole condiiton, but otherwize that's good.
ps It's usually quicker to try something simple like that yourself than to wait for someone to reply to you.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Use java.beans.XMLEncoder and pass it the ArrayList. It will encode the entire ArrayList and it's constituent classes and their ArrayLists of other classes and primitives all the way down.
Your custom classes just need to comply with JavaBeans standards (get/set/add methods, a no-args constructor).
It encodes to a Stream so you can do multiple encodes and subsequent decodes on the same stream/file.

I have a little demo using an ArrayList of instances of a class that contains another ArrayList among its instance variables, should you need convincing...

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

aren't editors column specific instead of cell specific?

It comes down to JTable's getCellEditor(int row, int column). Subclass JTable, override that method, and you have cell-specific editors

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Sorry.my mistake, I meant editors, not renderers.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

It's a combo box. It must have access to its list of values!

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Based on your current setup? I don't know. I would start with something simple like adding each renderer to a 2D array at the same time that I add it to the Table. That allows me to access (eg) all the renderers (and their associated data) in the same row etc.
I have to admit that I'm just making this up as I go. I simply don't have time to think it right through and build a test example. If I were doing this myself I'd start with something (see above), hack some skeleton code together and see how it works out. I wouldn't hesitate tp scrap it and start again if it turns out not work well.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

Each cell has its own renderer, which is a JComboBox, which has its own list of data to populate its values. It's those lists of data you need to update for your stated requirement. The TableModel isn't going to help when each cell has a list of values associated with it.

JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster

The "How to use JTables" Oracle tutorial shows how yto set a different renderer for any cell of the table (briefly: subclass JTable and override public getCellRenderer(int row, int column).
http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#renderer

Now each cell has its own renderer and each renderer can have its own underlying data. Updating the data is going to be a bit tedious to code, but nothing specially difficult.

OR (just to confuse things even more)

Go with Oracle's published strategy and implement your new GUI in JavaFX instead of Swing. The JavaFX table is far better at custyomising cells.
http://www.oracle.com/technetwork/java/javafx/overview/faq-1446554.html#6