NormR1 563 Posting Sage Team Colleague

wants it to have values a=1 b=2 c=3.

To make f('a') = 1 do this: subtract 'a' and add 1
'a' - 'a' + 1 = 1
'b' - 'a' + 1 = 2
etc

Are you confusing the hexidecimal values of hex digits with the values of chars?
The hex digit A represents the int value 10, B is 11 etc through F = 15

The int value of 'A' is 65

NormR1 563 Posting Sage Team Colleague

Comments:
The code is poorly formatted
If key is a String, why do this: key.toString() use key directly
What does this mean: subtracts 9 to make unicode into values A,B,C...=1,2,3...
'A' - 9 = 56 not 1

NormR1 563 Posting Sage Team Colleague

The class won't compile?!

Please post the full text of the error messages.

NormR1 563 Posting Sage Team Colleague

Please post the full text of the error message that shows where the error happens.
Look at the source line where the error happens and see what variable has a null value and then backtrack in the code to see why that variable does not have a valid non-null value.

NormR1 563 Posting Sage Team Colleague

If 'A' is 1, then is 'B' 2 and 'C' 3 etc to 'Z' 26?

'B' - 'A' + 1 = 2
'C' - 'A' + 1 = 3
'Z' - 'A' + 1 = 26

Subtract 'A' and add 1

That's it for tonight. Back tomorrow.

NormR1 563 Posting Sage Team Colleague

Good luck. I'm done for tonight. Back tomorrow.

NormR1 563 Posting Sage Team Colleague

Do what? Seems like a loop is easier. By using arithmetic, lines 16 to 145 can be replaced by one statement.

NormR1 563 Posting Sage Team Colleague

That code was an example for drawing one String at two different x locations. You will need to tailor it for your needs by changing the x and y values used by the drawString() method to be where you want the Strings drawn.

NormR1 563 Posting Sage Team Colleague
int x = 25;
g.drawString(k + " ", x, 50);
x = x + 100;
g.drawString(k + " ", x, 50);  // draw second at another location
NormR1 563 Posting Sage Team Colleague

You need to change the x and/or y values used in the drawString() method to draw the Strings at different locations.

NormR1 563 Posting Sage Team Colleague

Replace the list of if statements with a statement that returns the value for the character.
Since the values of the chars are contiguous: 'b' = 'a' + 1 and you can do arithmetic with char variables,
consider these: 'b' - 'a' = 1 or 'z' - 'a' = 25

NormR1 563 Posting Sage Team Colleague

Can you explain what your problems are? What happens when you compile and execute the code?

The paint() method is for painting/drawing on the graphics. Unrelated logic(lines 59 to 67) should be elsewhere in the program.

NormR1 563 Posting Sage Team Colleague

I could find any .java.policy folder

The file's name is .java.policy (its a file not a folder) and is located in the user.home folder. Use the policytool to create it and save it in that folder.
Don't change any of the files in the JDK or JRE's folders.

If you could write code to override permissions, then permissions would be meaningless.

NormR1 563 Posting Sage Team Colleague

to show my fellow staff members that I am making progress

Where is your attempt at writing the code in Java?

Here are a couple of links:
http://docs.oracle.com/javase/tutorial/java/TOC.html
http://docs.oracle.com/javase/tutorial/reallybigindex.html

NormR1 563 Posting Sage Team Colleague

For what? What is counterWords supposed to be used for?

NormR1 563 Posting Sage Team Colleague

I don't know how they are supposed to do it

That's the problem that you need to figure out.

If you were going to add up a list of numbers, how would you do it?
words.length contains the number of words in the current line that needs to be added to the tota number of words. What java statement will add that to the total: counterWords?

NormR1 563 Posting Sage Team Colleague

How many words were on the last line? 4 then add one = 5

Look at lines 28 & 29. How are they counting the words?
Explain what each of those two lines are doing.

NormR1 563 Posting Sage Team Colleague
NormR1 563 Posting Sage Team Colleague

Im having trouble counting the words

Can you explain? How many words does the program read and how many does it count?
What is the output from the program.

NormR1 563 Posting Sage Team Colleague

What about this: Add some more printlns to the sort() method code to print out the values of all the variables used to control the sorting. For example those that control the looping.

What statement in the main() method calls the lotteryGenerator() method? The code you posted does NOT call that method. It calls the constructor for the class.
Your IDE is doing some magic to allow this class to execute as you see it. The posted code does NOT display anything when it executes.

NormR1 563 Posting Sage Team Colleague

What statement in the main() method calls the lotteryGenerator() method? The code you posted does NOT call that method. It calls the constructor for the class.

Do all the println statements execute? You need to change what is printed by each println statement so you can tell which one has executed. There are 4 identical println statements that you won't be able to tell which one has printed and which one has not.
Add a different id number to each:
System.out.println("1before sort"+Arrays.toString(lotteryGenerator));

...
System.out.println("2before sort"+Arrays.toString(lotteryGenerator));

What about: Add some more printlns to the sort() method code to print out the values of all the variables used to control the sorting. For example those that control the looping.

What did you see with these print outs?

NormR1 563 Posting Sage Team Colleague

What prints out from your printlns? Are they all executing?

NormR1 563 Posting Sage Team Colleague

The method public void lotteryGenerator() that fills the JFrame and sets it visible is not called anywhere in the posted code. How does your version of the code work?
There must be some other code somewhere with a constructor for your class that calls the above method.

NormR1 563 Posting Sage Team Colleague

Add some more printlns to the sort() method code to print out the values of all the variables used to control the sorting. For example those that control the looping.

The code you have posted does not display anything when compiled and executed.
How are you compiling and executing it? Are there other java files that you have not posted?

NormR1 563 Posting Sage Team Colleague

it just seemed to ignore it.

Please explain. Did the printlns execute before and after the sort?

Add some more printlns to the sort method code to print out the values of all the variables used to control the sorting.

NormR1 563 Posting Sage Team Colleague

The code still does nothing when executed. Did you copy the posted code to an empty folder and compile and execute it to see what it does? Don't mix it in with anything else.

How are compiling and executing the code?

NormR1 563 Posting Sage Team Colleague

Copy the above code into an empty folder, compile and execute it and tell me what happens.
What you have posted does not display anything.

To see if the methods are changing the contents of the array, print the array out at the beginning and end of the method by using the Arrays toString() method to format the contents of the array:
System.out.println("before shuffle"+Arrays.toString(lotteryGenerator));

NormR1 563 Posting Sage Team Colleague

The posted code doesn't display anything when compiled and executed.
Are you sure that you have posted the correct code?

NormR1 563 Posting Sage Team Colleague
NormR1 563 Posting Sage Team Colleague

On paper, Make a table of the rates based on the ages. For example:
age rate
1-12 400
13-25 600
26-50 300
51-65 350
66-90 500

Then in the program use if statements to select the rate base on the age as set in the table of rates you have decided on.

NormR1 563 Posting Sage Team Colleague

Sorry, I don't have any design for you.

NormR1 563 Posting Sage Team Colleague

Can you post what the csv file would look like given the XML you posted for input?

NormR1 563 Posting Sage Team Colleague

You need a design/algorithm before you can write any code.

NormR1 563 Posting Sage Team Colleague

What have you written so far? Do you have any specific questions about your assignment?

jalpesh_007 commented: you're right. +3
NormR1 563 Posting Sage Team Colleague

Are you looking for a design/algorithm
or do you have one and need help coding it in java?

NormR1 563 Posting Sage Team Colleague

Look at using the Card layout for switching from one display to another.

NormR1 563 Posting Sage Team Colleague

Events like key presses don't work that way. You need to use a listener that is called when the event happens. The code should show a window with a button and then exit to the jvm to await the user pressing the button. When the button is pressed, the event listener is called.

If you want to pause the execution of a method, you might be able to use something like the wait() notify() methods. Call wait() in at the place you want to pause execution and call notify() for that wait() in the listener method.

NormR1 563 Posting Sage Team Colleague

I have no idea what formula you need. You need to get that from the person that gave you the assignment.
I'd assume there would be a rate based on ranges of ages: higher for younger drivers, average for middle aged people and then higher for the very old.
Larger engines could be more expensive,
No idea what license would do to the rate.

NormR1 563 Posting Sage Team Colleague

do some action only when enter is pressed

Put the code in the listener that is called when Enter is pressed.

NormR1 563 Posting Sage Team Colleague

What code have you written so far? Do you have any specific problems or questions to ask about it?
Post your code and your questions so we can help you get your code to work.

NormR1 563 Posting Sage Team Colleague

That location is different from mine. I'm not sure if the file in that location is the one used by by the java program. Can you explain how it got to that location?
Also you say the filename is java.policy NOT .java.policy

The permission to allow all files to be accessed:
permission java.io.FilePermission "<<ALL FILES>>", "read,write,execute";

NormR1 563 Posting Sage Team Colleague

Add just one println statement inside the draw() method (after line 25) that prints the values of all the variables used in the draw() method.

NormR1 563 Posting Sage Team Colleague

Try debugging the code by printing the values of the variables used in the draw() method to see where the fillRect() method is drawing.

NormR1 563 Posting Sage Team Colleague

There should NOT be code in the paint method to set background and size in the paint() method.

Try debugging the code by printing out the values of all the variables used in the draw() method to see where the fillRect() method is doing its thing.

NormR1 563 Posting Sage Team Colleague
NormR1 563 Posting Sage Team Colleague

Create a Person class with the listed fields and have a List that contains Person objects.

NormR1 563 Posting Sage Team Colleague

:Expected end of line, etc. but found identifier.

Please post the full text of the error message that shows the source line where the error happened.

NormR1 563 Posting Sage Team Colleague

Break that down into a list of the detailed steps the program needs to do. What you have written is a very high level description of what needs to be done. For example here are the starting steps:

Ask user for name of file to read
read name of file
open the file so it can be read
... fill in the rest of the steps
What are the steps to count the number of characters? the number of words, the number of lines?

NormR1 563 Posting Sage Team Colleague

Before writing code, work on the logic for what the code should do. Don't try writing code until you know what you want the code to do.
Post the steps the code should do here and we'll try to get them in order before writing code.

NormR1 563 Posting Sage Team Colleague

(I'm getting a infinite while loop

Add some println calls in the loop that prints out the value of numberOfChar to see what the code is reading that makes it loop forever.

Have you read the API doc for the Scanner methods to see what they can do? For example they can block waiting for input.

You need to work out the logic for your program before writing code. The code that you posted doesn't do anything like what the assignment states.