javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Your project's description doesn't make much sense. But if you want to start, just create a method that takes as argument the score and by using if statements return the result.
Then call that method from the main. Search for examples on how to read input from the keyboard using the Scanner class and post some code

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Does this refer to a web application and JSP? If yes, put an onclick event at the button and then call this:

window.location.href="your url"

For more information read some tutorials here: http://www.w3schools.com/default.asp

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Have a JFrame with a JTextArea and the buttons: Save, Load, Compile, Run. And a way for the user to select a file for loading or saving. (JFileChooser)

The user will write his code in the text area and with the buttons you will perform the actions.
Save: You will read what the user entered and save to a file.
Do the same for the rest.

For compile and run, I would suggest you study how to run command prompt commands with java using the Process class. Just run the javac command to compile.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

After a quick look at the API of the JTextField, (which you should always read whenever you have a problem), I found this method:
addInputMethodListener.
It is inherited by the super class: JTextComponent.

I have never used it, but I believe that you should try to add an InputMethodListener to all of your TextFields. If you do that and implement the method: inputMethodTextChanged of the InputMethodListener interface, that method will be called whenever you change the text of your fields. So just take the text entered from the event argument and check the text field has any.

Try to experiment by adding System.out.printlns to your code.

The inputMethodTextChanged takes as argument a InputMethodEvent. Try to make changes to a field that has that listener and then print that event and see if you can find something that you can use

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

When you put this in the code: int N=Integer.parseInt(args[0]); , you are supposed to pass arguments to your program when you run it. (args[0])

Don't expect to copy code from the internet and run it without putting any effort to understand it.

Have you tried the link new_programmer has provided?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

There are several ways. If you want to keep the code as it is then you can put on click events and change the type to button. You can have 3 different forms with their own submit buttons. Or you can put check-boxes or select-options instead of submit buttons.

One quick example is this:

<html>
<head>
  <title>Page 1</title>
</head>
<body>
<form method="post" name="formName" action="page2.jsp" >

  <input type="hidden" name="person" value="" />

  <table>
    <tr>
      <td>John Doe</td>
      <td><input id="name1" name="name1" type="button" value="Edit" 
onclick="document.formName.person.value='John Doe';" /></td>
    <tr>
    <tr>
      <td>Steve Smith</td>
      <td><input id="name2" name="name2" type="button" value="Edit" 
onclick="document.formName.person.value='Steve Smith';" /></td>
    <tr>
    <tr>
      <td>Peter Pipper</td>
      <td><input id="name3" name="name3" type="button" value="Edit" 
onclick="document.formName.person.value='Peter Pipper';" /></td>
    <tr>
  </table>
</form>
</body>
</html>

Search for tutorials at the w3schools about javascript and then about HTML DOM
By doing this: document.formName.person.value, You access the form with name="formName" then you access the input with name="person" and then you change its value.

What you do when you submit, you pass at the request the input field "person".

You can also have javascript that changes the action value of the form. If you don't want that hidden field you can have the onclick event to do this:
document.formName.action='page2.jsp?person=Peter Pipper'

At the page2.jsp use the request.getParameter("person") to take the value.

Don't forget to study this: http://www.w3schools.com/default.asp
You can find a complete reference of the HTML tags, how to use javascript and how to access the elements with DOM

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

That code has nothing to do with what I suggested. Also why do you loop until length-1 and not length?
Use my suggestions to create an array of characters and loop it. In order to change every third character in the loop have an if statement that checks if that index of the array can be divided by 3. Use the '%' operator:

14%2 = 0
14%7 = 0

3%3 = 0
6%3 = 0
9%3 = 0

If it returns 0 then it can be divided:

int a = 5;
int b = 2;
int mod = a%b;

If the index of the array can be divided then change it with the 'X' as explained in my first post. Then convert that char array to a String. Look at those methods at the String API

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Convert the String to an array of characters (look the java String API)
Loop the array and for every third element set its value to X (array = 'X')
Then convert that array of characters to a new String (look the java String API)

http://download.oracle.com/javase/1.4.2/docs/api/java/lang/String.html

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can try adding a few print messages between your calls in order to see that happens. For example:

int num = 0;
Book[] bookInfo = new Book[num];
 
System.out.println("Length before Choice1: "+bookInfo.length);
Choice1(bookInfo);
System.out.println("Length after Choice1: "+bookInfo.length);

Choice2(bookInfo);

There also is a better design for your problem:

Book[] bookInfo = Choice1();
Choice2(bookInfo);

public static Book[] Choice1()    
    {
        System.out.print("Number of books to enter: ");
        Scanner keyboard = new Scanner(System.in);
        int num = keyboard.nextInt();

        Book [] bookInfo = new Book[num];

        for(int i = 0; i < bookInfo.length; i++)
        {
            System.out.println();
            bookInfo[i] = new Book();
            bookInfo[i].readInput();
            System.out.println();
        }

        return bookInfo;
    }
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Create a new array big enough to hold both array's elements and then loop them in order to set their values into the big array

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

No you don't use the lastindexOf I know with arrays. When you say you know how to use that method, which class does this method belong to. Are you referring to the method of the String class?
Better explain your problem.

As for writing and calling methods there are plenty of tutorials you can read and we are not here to repeat those tutorials to you. You can learn those things on your own. Just study your notes on how to declare methods.

But we are here to help with the logic, so explain what your method should do.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
fgfgfgjgjdhtjghdhtjdgjgjghj

Start a new thread.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I would like to add something else. Your first constructor is wrong:

public ParkedCar(String mk, String mod, String col, String lic, int min)
{
  mk = make;
}

Here you take the value of make(local attribute) which is null and you assign it to the argument. The idea is to take the argument and put it into the local attribute.
You correctly do that in your second constructor:

public ParkedCar(ParkedCar car2)
{
  make = car2.make;
}

You take the argument car2.make and put it into the make. So do the same at the first constructor:

public ParkedCar(String mk, String mod, String col, String lic, int min)
{
  make = mk;
  model = mod;
}
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The call: "solve(diskNumber-1, Aux, Src, Dst)" will execute after the first call has finished: "solve(diskNumber-1, Src, Dst, Aux)" But don't forget that this is also a recursive call. don't expect this execution:

>solve(diskNumber-1, Aux, Src, Dst)
>solve(diskNumber-1, Src, Dst, Aux)

After the first call the same method will be executed, and it will execute:

>solve(diskNumber-2, Aux, Src, Dst)
>solve(diskNumber-2, Src, Dst, Aux)

But the second call again will not execute until the first, which is recursive, so you will get:

>solve(diskNumber-3, Aux, Src, Dst)
>solve(diskNumber-3, Src, Dst, Aux)

When the first finishes then this will be called:
>solve(diskNumber-3, Src, Dst, Aux)

And then the
>solve(diskNumber-2, Src, Dst, Aux)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Use proper English and search the Yahoo to find your answer. We are not going to open our books for you and start typing the entire explanation. That is something you can do without our help.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

In case you haven't noticed masijade, this is the second time this poster made that question:
http://www.daniweb.com/forums/thread317619.html

In that post he received the appropriate answer. Apparently he didn't like it so decided to double post.

Same on you bonafos. No one here is going to give you the code. Show some effort. In your first post you were given plenty of advices in order to begin.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

And? How should we help you? What kind of help do you need? Can't do a little search on your own to find the tutorials that you need? At the top of this forum you will plenty tutorials about java, not NetBeans.

NetBeans is an IDE, you need to learn JAVA

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You need to look again the whole code: This is wrong, as you know

while () {

}
} // this is an extra bracket

This would work:

if () {
  while () {

  }
}

You need to look the code. Better begin with a new class, and start adding slowly code to it from the previous one, and compile regularly in order to find what you added was wrong.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Do you have a data structure with all the jobs and their times:
shortest start, shortest finish, longest start, longest finish? (I don't know the English terminology)

I don't see where you save those values. Have an array for example with the jobs and their times. Then create a new Frame that takes as argument those values and draw some graphs.

When I was making my own GANTT chart, I used rectangulars with a fixed width and the length was the duration.

Draw the 1st job at position (X,Y)=(0,0) with width and length=duration.
Then as the loop progresses, draw the ith rectangular(job) at position below the previous rectangular (previous position: X + width) and to the right moved by the previous's length (previous position: Y + length)

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

But if those files already exist, you can look at the java.io.File API. There you will find what you need. Always look the API.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

That is because you never call the reduce. It needs to be put in the constructor so no matter what the user enters your variables will have the right values.

public Fraction(int numerator, int denominator) throws Exception {
	top = numerator;
	bottom = denominator;

	if (bottom == 0);
	    throw new Exception("Attempt to create zero denominator fraction");

        reduce();
	}

With that way in your plus,minus,... methods when you create a new instance and return that object you will have the right values.

Also if you insist on having RuntimeError, change the throws I have at the constructor, but it is advisable to use Exception instead

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I have no idea.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

30X30=900

It is a simple multiplication. If it is for finals, then how is it possible that you don't know how to declare 2 int variables, multiply them and assign the result to a third int variable and then print it?
Or even how to read from the input.

Search this forum for examples no how to read input from the keyboard by using the Scanner class.

And I doubt that this 30X30 is a special project.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you don't know what are those values, then how could we know? Don't you have a way to read them from somewhere?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You have a problem with your brackets. After removing some of the code inside the ifs and the whiles, you have something like this:

while () {

} else if () {

}

Which is wrong. Try from the start and this time try to open-close, and then write the code in between.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Can't you put variables in the values of your url? How do you create that url and how did you put in your code?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

One simple way is this:

<input type="button" value="Login" name="btnLogIn" onclick="val()" />

And at the val function:

function val(){

        if(document.getElementById("txtAdminId").value.length==0){
            alert("Please Enter Your ID");
        } else if(document.getElementById("txtAdminPassword").value.length==0){
            alert("Please Enter password.");
        } else {
             document.frmAdminLogin.submit();
         }
     }

If you want to have your button to be of type 'submit' then:

<form name="frmAdminLogin" action="AdminLogin" method="post" onsubmit=" call the method here ">

...

<input type="submit" value="Login" name="btnLogIn" />

</form>

If you want the later way the method at the onsubmit event must return true or false. I don't remember if you must enter it like this:
onsubmit="return val();"
OR
onsubmit="val();"

But I do know that val in this case must return boolean

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

give me the source code to my e-mail id

Read the previous posts. Start a new thread.
And we don't give away homework or give code through emails or PMs. It is against the rules to post your email asking for help.

If you want help start a new thread with specific questions.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I don't believe that you need to put login.java. When you create a servlet it is defined in an xml file where the name of the servlet is set as well as the java class file. So there is a mapping between the servlet name and the class file. Netbeans does that automatically so I believe that if you put action="login" it should work. That is probably the name that NetBeans has given

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Post your code. There are various way to do that. If you say that you have javascript that executes then post your code.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Just declare the classes with the methods described. Then in the first class have your main method and call the other methods. Study how you create classes, declare methods and call them.
You will also need the help of the java API:
java.lang.String

For the second class:

public class LowerCase {
   public static String convertToLowerCase(String input) {
      if (input==null) return "";
      return input.toLowerCase();
   }
}

The 'toLowerCase' method is a method of the String class you can call.

Then in the main method of the first class call it:

String s1 = "ABC";
String s2 = LowerCase.convertToLowerCase(s1);

The names of the classes, methods are random. You can call them anyway you want. Just make sure the class name matches the file name of the class.

Similar you will do the third class with the methods described and the help of the API

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Is it not possible to Stretch the image JLabel!
or it is possible , if yes plz post the code for me..........

I haven't tried it but here is a suggestion, you can use.


The JLabel constructor takes as argument an Icon. Actually you call it with argument an ImageIcon which is the class that implements the Icon class:

ImageIcon icon = new ImageIcon("file name");
JLabel label = new JLabel(icon);

The JLabel has a method that returns that Icon: getIcon()

So just take that ImageIcon instance. If you see the API of that class there is a method getImage.

ImageIcon icon = new ImageIcon("file name");
Image img1 = icon.getImage();

Take a look at the Image API. There is a method called getScaledInstance. That is the method that you need:

ImageIcon icon = new ImageIcon("file name");
Image img1 = icon.getImage();
Image img2 = img1.getScaledInstance(.....);

Now that you have the new img2 scaled instance, you can use it to create a new ImageIcon instance (by using the right constructor from the API)
and then with that ImageIcon instance you can change the icon of the JLabel with the setIcon method of the JLabel API.


Just take a look at the API of those classes:
javax.swing.JLabel
javax.swing.ImageIcon: This one implements the Icon interface that the JLabel uses
java.awt.Image: For you to use the getScaledInstance method

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

No one is going to give you the code. Java is similar to C. If you wrote this code, do some studying and you will have no problem converting yourself. If you have any problems post you JAVA code.

If you didn't write it no one is going to help you cheat.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

The way you post is irritating. You post some code get suggestions for that code and you post something entirely different as if you ignored those who tried to help you.

Keep in 1 post your code and the error message you get and where. Posting just the lines will not help. we are not going to count X number of lines to find the error. Indicate where the error is.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Did you even read out suggestions? That has nothing to do with what you have been told.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

wht do i have to do now?

You have your extended JPanel. Add whatever you want to be displayed to it. Then create an instance of it and add it to a JFrame, or your extended JFrame. Then make that JFrame visible. You already do what I just described in your original code. The problem was with the JPanel class. Just give it a try.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Hi javaAddict.
OP has a panel (class DescriptionPanel)already populated with components, so all he needs to do is to create the JFrame, add an instance of his DescriptionPanel and make the JFrame visible.

If we all go back to the OP's very first post - that's exactly what his original code wasdoing, it's just one line of declaration failed to reference his DescriptionPanel class properly.

You are right to what you are saying and I am aware with the code the OP was using. But since it was so confusing, and we have seen different codes in various places in this thread I thought it would be a good idea to give the general idea and wait for the posters latest code.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Just create a JFrame instance and a JPanel instance. Add your components to the JPanel, then add the JPanel to the JFrame and make the JFrame visible.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

Norm 1 RUN THE CODE!! then YOU WILL SEE THE PROB.

No need to shout. The problem has already been spotted. No need to run the program. Norm1 has told you what the problem is. Read his post. Not to mention that the error message says the same thing, which you didn't bother to spend 2 seconds try to understand it

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

This assignment doesn't look like something you assign to a student that has been doing java for a few weeks. So I must assume that your teacher has told you everything you need to know in order to solve this. If you have never studied during the entire course that is your problem. We help only those who show effort.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

can u give me some code that helping me making simple addressbook?

thats have output

attributes | description
name |
address |
telnum |
email add |

using util scanner

and provide nesscesarry accessor and mutator methods all the attributes

and creating object provide
add entry, delete entry view entries,, update entry

Start a new thread with your question and your code.
As far as your question:
since you posted in this thread, you should have read it and saw that your question has been answered. This thread has the code and examples that you need to get you started.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

What you ask consist of many technologies. A small example is not going to be enough and none here is going to spend time writing code that has already been written many times in this forum.

Where are you having problems with? Displaying the combo boxes, firing the "change" event, writing sql, connecting to the database.

Start by writing some code. Write the first 2 combo boxes and when one of those two is clicked write some code that prints their values.

Once you have done that write a method that connects to the database and retrieves the data you want. Then call that method when one of those boxes is clicked clicked at the place where you printed the values of the boxes.

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

how should I set the data being entered by the user in main...please give an example how..

And what have I been doing in the last posts?
All that code and examples aren't they enough?

You have your main; you are already reading the data from the keyboard; and setting them to the array. The examples given answer exactly your questions. It is not as if I do not want to answer your question because I already have answered it. I even implemented one of the methods (add) for you, and told you how to do the others. Posting the same code and giving the same explanations is a waste of time. My time.

Antenka commented: WOW. That's even more than impressive. I think, this is the best example of patience, that I've ever seen. You'd be a great teacher ;) +2
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

In previous posts I showed how to use one array and input multiple values:

add(String name, int age, ....) {
  EmployeeRecord er = new EmployeeRecord();
  er.setName(name); ....

  array[count] = er;
  count++;
}

OR

array[count] = new EmployeeRecord();
array[count].setName(name);
array[count].setAge(age);

count++

It is based on the correct code you posted that had 2 classes. One class is the object EmployeeRecord and the other your main method in which you will define the array as explained

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

If you think that is is correct according to your requirements then fine by me. But you have only one array for the names, what about the others?

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can convert the int to a String. It will be easier then. Check the String class API.

int i = 123;
String s = String.valueOf(i); // now s="123"

// then use the String methods
char [] ch = s.toCharArray();

You can loop the array backwards and generate a new String from that. Then you can compare the original String with the new String to see if it is a palindrome.

If this approach is not allowed by your teacher and you need to use only mathematics and numbers then let us know

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

You can also have the 60 to be the argument:

package hotpotato;

/**
 *
 * @author Josh
 */
public class Main {
public static void heatLoss (double m, double tO, double tA, int minutes) {
    for (int i = 1; i <= minutes; i++) {
    // int n represents 60 minutes,
double tN = (tO - m * (tO - tA));
// Defines tNew
System.out.println ("New temperature: " + tN);
// Output New Temp
tO = tN;

    }
    }
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        heatLoss (.5, 100, 90, 60);
    }
        // TODO code application logic here
    }
javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster
for (int i = 1; i == 60; i = i +1) {

The loop executes as long the condition: i==60 is true. If it is false the loop exits.
So you begin with i=1. Then the condition is checked: i==60 which is false, so the loop exits without doing anything.
You want the loop to executes for i=1,2,3,4,....60. So you want i<=60

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

There aren't such problems. Be more descriptive on what you are trying to accomplish

javaAddict 900 Nearly a Senior Poster Team Colleague Featured Poster

I have never replied to your PMs. In all of my replies I was telling that I answer only to the forum. Why you think that I would do now. And you have already posted your entire code here. Now suddenly you fear that somebody might see it.

Not to mention that completely ignored my previous post.

Your code that you posted here works. You have 2 files. One is the EmployeeRecord that represents one employee and the other is the one with the main. Why did you mix them in the PM. Create an array EmployeeRecord in the main class and call its methods. You can have many different class files and create and call their methods from wherever you want in any class you want.

String is a class. You called it like this:

String s = "aa";
int length = s.length();

You use that String class in your main class.
The same for the EmployeeRecord

EmployeeRecord emp = new EmployeeRecord();
emp.setName("my name");

So in your EmployeeRecordTest instead of having a String array:

private String emp[];

...

emp = new String[5];

...

emp[count] = name;
count++;

Have the EmployeeRecord class:

EmployeeRecord [] emps = new EmployeeRecord[size];

...

emps[count] = new EmployeeRecord();
emps[count].setName(name);
count++;

You don't need to change anything in the structure of the EmployeeRecord.

You have been given examples on how to make an array of your EmployeeRecord class and use it. Given suggestions on what to do …