Hi there, need help for this program...thx!

Hi there guys,
I have created this applet program that requires a user to login with a user no, and a password. I am using arrays as to store the defined variables,(as required by my project supervisor). My problem here is that when the arrays are declared in class validateUser(), the program would run fine, but i cant login and i get a NullPointerException error. if the arrays are located in actionPerformed, i get a 'cannot resolve symbol' error for the method 'get' and 'if (Admin.equals(admins.get(i).toString())) ' as well as 'if (Password.equals(passwordsget(i).toString())) '. I am not very effecient in java, hence the untidy program (and i have to admit, it isnt any good), so sorry for any inconvenience caused. Once agani thx in advance ;)
here are my codings :
import java.applet.Applet;
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import java.io.*;
import java.net.URL;
import java.net.*;
import javax.swing.*;
import java.lang.*;
import java.util.Vector;
public class eg31662 extends Applet implements ActionListener
     Panel panel1, panel2, panel3, panel4, panel5;
     Button login, enter;
     Label inst, top, admin, pass, fieldlabel;
TextField adminF, passF, field;
String Admin, Password;
Vector admins, passwords;
     Thread thread = null;
     boolean status = false;
          public class validateUser extends Applet
               String[] admins = {"User1", "User2", "User3"};
               String[] passwords = {"P1", "P2", "P2"};
     public void init()
          setLayout (new BorderLayout());
          panel1 = new Panel(new FlowLayout());
          panel2 = new Panel(new FlowLayout());
          //login button
          login = new Button("Login");
          //instruction
          inst = new Label("Please type in your User no. and the given password in order to proceed");
          //label
          top = new Label("Login login");
          admin = new Label("Admin No :");
          pass = new Label("Password :");
          //input textfields
          adminF = new TextField(8);
          passF = new TextField(10);
          passF.setEchoChar('*');
          panel1.setBackground(Color.gray);
          panel2.setBackground(Color.orange);
          panel2.add(admin);
          panel2.add(adminF);
          panel2.add(pass);
          panel2.add(passF);
          panel2.add(login);
          panel2.add(inst);
          panel1.add(top);
          add(panel1, BorderLayout.NORTH);
          add(panel2, BorderLayout.CENTER);
          login.addActionListener(this);
          setSize(500,400);
     void mainpage()
          boolean flag = true;
          setLayout (new BorderLayout());
          panel1 = new Panel(new FlowLayout());
          panel2 = new Panel(new FlowLayout());
          top = new Label("Welcome");
          enter = new Button("Enter");
          panel2.setBackground(Color.orange);
          panel1.setBackground(Color.gray);
          fieldlabel = new Label("Type something here :");
          field = new TextField(20);
          add(panel1, BorderLayout.NORTH);
          add(panel2, BorderLayout.CENTER);
          panel2.add(fieldlabel);
          panel2.add(field);
          enter.addActionListener(this);
     public void start() {
          if(thread == null) {
               status = true;
     public void stop() {
          status = false;
     public void run() {
          while(status == true) {
               try {
                    thread.sleep(50);
               catch(InterruptedException ie) {
               repaint();
          thread = null;
     public void actionPerformed(ActionEvent ev)
               //String[] admins = {"User1", "User2", "User3"};
               //String[] passwords = {"P1", "P2", "P3"};
          if(ev.getSource() == login)
               Admin = adminF.getText();
               Password = passF.getText();
          boolean ok = true;
          for (int i = 0; i < admins.size(); i++) {
          if (Admin.equals(admins.get(i).toString())) {
          if (Password.equals(passwords.get(i).toString())) {
          ok = true;
          this.setVisible(false);
          //break;
                         JOptionPane.showMessageDialog(null, "Welcome, u have successfully logged in");
                         mainpage();
          else {
          ok = false;
          else {
          ok = false;
          if (ok == false) {
                         JOptionPane.showMessageDialog(null,
                    "Incorrect Password or Admin No, Please Try Again",
                    "Access Denied",
                    JOptionPane.ERROR_MESSAGE);
          else {
          this.setVisible(false);
}

Hi, sorry to bring this thread up again, but this is actually a continuation from my previous posted program. Hope u guys can help me again!
Right now i'm supposed to come up with a simple quiz program, which consists of the center panel displayin the question (in a pic format), and a textfield to enter the answer at the lower panel. this goes on for a couple of pages and once it is completed, the final page would display the total correct answers out of the number of questions, as well as the score in percentage form.
The few(or many) problems taht i'm facing are :
1)How do i save the answers that are typed in each textfieldAnd later on checked for the correct answer based on the array given?
2)How do i go about doing the final score in percentage form and total of correct answers?
3)I previously tried out using canvas, but it didnt seem to work. my questions(pictures) that are supposed to displayed in the center(canvas) produce nothing. How do i rectify that?
i'm really sorry for the mess in the codings, hope this wouldnt be a hassle for any of u out there. Once again thanks in advance!
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.io.*;
import java.net.URL;
import java.net.*;
import java.util.Vector;
import javax.swing.*;
import java.awt.image.*;
import java.lang.*;
import java.awt.Graphics;
public class eg31662 extends Applet implements ActionListener
    Panel panel1, panel2, panel3, panel4, panel5;
    Button login, enter;
    Label inst, top, admin, pass, startLabel;
    TextField adminF, passF, field;
    String Admin, Password;
    Vector admins, passwords;
     //Quiz declarations
     TextField ansF1,ansF2,ansF3;
     Button startBut, next0, next1, finishB, previous1;
     Image q1, q2, q3;
     Image ques[] = new Image[2];
     boolean text = false;
     boolean checked = false;
     int correct = 0;
     String [] answer = new String [2];
     String [] solution = {"11", "22", "33"};
     boolean text = false;
     boolean sound = true;
     int red,green,blue;
     int question =0;
     int good = 0;
     boolean pause= false;
     boolean start = true;*/
    Thread thread = null;
    boolean status = false;
    public void init()
        validateUser();
        setLayout (new BorderLayout());
        panel1 = new Panel(new FlowLayout());
        panel2 = new Panel(new FlowLayout());
        panel3 = new Panel(new FlowLayout());
        //login button
        login = new Button("Login");
        //instruction
        inst = new Label("Please type in your UserName and the given " +
                         "password in order to proceed");
        //label
        top = new Label("Top Label");
        admin = new Label("User Name :");
        pass = new Label("Password :");
        //input textfields
        adminF = new TextField(8);
        passF = new TextField(10);
        passF.setEchoChar('*');
        panel1.setBackground(Color.gray);
        panel2.setBackground(Color.orange);
          panel3.setBackground(Color.gray);
        panel2.add(admin);
        panel2.add(adminF);
        panel2.add(pass);
        panel2.add(passF);
        panel2.add(login);
        panel3.add(inst);
        panel1.add(top);
        add(panel1, BorderLayout.NORTH);
        add(panel2, BorderLayout.CENTER);
        add(panel3, BorderLayout.SOUTH);
        login.addActionListener(this);
        setSize(500,400);
    private void validateUser()
        String[] adminData    = {"t", "User1", "User2", "User3"};
        String[] passwordData = {"t", "P1", "P2", "P3"};
        admins = new Vector();
        passwords = new Vector();
        for(int j = 0; j < adminData.length; j++)
            admins.add(adminData[j]);
            passwords.add(passwordData[j]);
    private void Mainpage()
        boolean flag = true;
        removeAll();  // remove all components from container
        panel1 = new Panel(new FlowLayout());
        panel2 = new Panel(new FlowLayout());
          panel3 = new Panel(new FlowLayout());
        top = new Label("Welcome");
        enter = new Button("Enter");
        panel2.setBackground(Color.orange);
        panel1.setBackground(Color.gray);
        panel3.setBackground(Color.gray);
        startLabel = new Label("Welcome! " +
                                      "Please click on the 'Start' button to begin the quiz ");
          startBut = new Button("Start");
          startBut.requestFocus();
          Dimension dim = getSize();
          startBut.setSize(50,20);
        add(panel1, BorderLayout.NORTH);
        add(panel2, BorderLayout.CENTER);
        add(panel3, BorderLayout.SOUTH);
        panel2.add(startLabel);
        panel2.add(startBut);
        startBut.addActionListener(this);
        validate();
        repaint();
    private void Quiz1()
          //quizCanvas = new Canvas();
        boolean flag = true;
        removeAll();  // remove all components from container
        panel1 = new Panel(new FlowLayout());
        panel2 = new Panel(new FlowLayout());
        panel3 = new Panel(new FlowLayout());
        panel1.setBackground(Color.gray);
        panel2.setBackground(Color.orange);
        panel3.setBackground(Color.gray);
        add(panel1, BorderLayout.NORTH);
        add(panel2, BorderLayout.CENTER);
        add(panel3, BorderLayout.SOUTH);
          q1 = getImage(getDocumentBase(), "1.gif");
          ques[0] = q1;
          //ques[1] = q2;
          //previous = new Button("<");
          next0 = new Button("Done");
        ansF1 = new TextField(25);
          next0.addActionListener(this);
          //quizCanvas.insert(ques1);
        //panel3.add(previous);
        panel3.add(next0);
        panel3.add(ansF1);
        //panel2.add("1.gif");
          ansF1.requestFocus();
          ansF1.setText("focussing");
        validate();
        repaint();
     public void Quiz2(){
        boolean flag = true;
        removeAll();  // remove all components from container
        panel1 = new Panel(new FlowLayout());
        panel2 = new Panel(new FlowLayout());
        panel3 = new Panel(new FlowLayout());
        panel1.setBackground(Color.gray);
        panel2.setBackground(Color.orange);
        panel3.setBackground(Color.gray);
        add(panel1, BorderLayout.NORTH);
        add(panel2, BorderLayout.CENTER);
        add(panel3, BorderLayout.SOUTH);
          q2 = getImage(getDocumentBase(), "2.gif");
          ques[1] = q2;
          next1 = new Button("Done");
        ansF2 = new TextField(25);
          next1.addActionListener(this);
        panel3.add(next1);
        panel3.add(ansF2);
          ansF2.requestFocus();
          ansF2.setText("focussing");
        validate();
        repaint();
     public void Quiz3(){
        boolean flag = true;
        removeAll();  // remove all components from container
        panel1 = new Panel(new FlowLayout());
        panel2 = new Panel(new FlowLayout());
        panel3 = new Panel(new FlowLayout());
        panel1.setBackground(Color.gray);
        panel2.setBackground(Color.orange);
        panel3.setBackground(Color.gray);
        add(panel1, BorderLayout.NORTH);
        add(panel2, BorderLayout.CENTER);
        add(panel3, BorderLayout.SOUTH);
          q3 = getImage(getDocumentBase(), "3.gif");
          ques[2] = q3;
          finishB = new Button("Finish");
        ansF3 = new TextField(25);
          finishB.addActionListener(this);
        panel3.add(finishB);
        panel3.add(ansF3);
          ansF3.requestFocus();
          ansF3.setText("focussing");
        validate();
        repaint();
    public void start() {
        if(thread == null) {
            status = true;
    public void stop() {
        status = false;
    public void actionPerformed(ActionEvent ev)
        boolean ok = true;
        if(ev.getSource() == login)
            Admin = adminF.getText();
            Password = passF.getText();
            for (int i = 0; i < admins.size(); i++) {
                if (Admin.equals(admins.get(i).toString())) {
                    if (Password.equals(passwords.get(i).toString())) {
                        ok = true;
                        JOptionPane.showMessageDialog(null,
                                    "Welcome, u have successfully logged in");
                        Mainpage();
                        break;
                    else {
                        ok = false;
                else {
                    ok = false;
            if (!ok) {
                JOptionPane.showMessageDialog(null,
                              "Incorrect Password or Admin No, Please Try Again",
                              "Access Denied",
                               JOptionPane.ERROR_MESSAGE);
        if(ev.getSource() == startBut)
               Quiz1();
          if (ev.getSource () == next0) {
               saveanswer();
               Quiz2();
          if (ev.getSource () == next1) {
               //saveanswer();
               Quiz3();
          if (ev.getSource () == finishB) {
               //saveanswer();
               //checkanswer();
     /*class quizCanvas extends Canvas {
          private Image quest;
          public quizCanvas() {
               this.quest = null;
          public quizCanvas(Image quest) {
               this.quest = quest;
          public void insert(Image quest) {
               this.quest=quest;
               repaint();
          public void paint(Graphics g) {
     public void checkanswer() {
          if (!checked) {
          /*question = 0;
               for (int a=1;a<16;a++) {
                    question++;*/
                    if (ansF1) {
                         if (answer[1].toUpperCase().equals(solution[1])) {
                              correct++;
                    if (ansF2) {
                         if (answer[2].toUpperCase().equals(solution[2])) {
                              correct++;
                    if (ansF3) {
                         if (answer[3].toUpperCase().equals(solution[3])) {
                              correct++;
          checked = true;     }
     public void saveanswer() {
          if (text) {
               if (!ansF1.getText().equals("")) {
                    answer [Quiz1] = ansF1.getText();
               //answer2[question] = tf2.getText();
               if (!ansF2.getText().equals("")) {
                    answer [] = ansF2.getText();
               if (!ansF3.getText().equals("")) {
                    answer [] = ansF3.getText();
}

Similar Messages

  • Pls i need help for this simple problem. i appreciate if somebody would share thier ideas..

    pls i need help for this simple problem of my palm os zire 72. pls share your ideas with me.... i tried to connect my palm os zire72 in my  desktop computer using my usb cable but i can't see it in my computer.. my palm has no problem and it works well. the only problem is that, my  desktop computer can't find my palm when i tried to connect it using usb cable. is thier any certain driver or installer needed for it so that i can view my files in my palm using the computer. where i can download its driver? is there somebody can help me for this problem? just email me pls at [email protected] i really accept any suggestions for this problem. thanks for your help...

    If you are using Windows Vista go to All Programs/Palm and click on the folder and select Hot Sync Manager and then try to sync with the USB cable. If you are using the Windows XP go to Start/Programs/Palm/Hot Sync Manager and then try to sync. If you don’t have the palm folder at all on your PC you have to install it. Here is the link http://kb.palm.com/wps/portal/kb/common/article/33219_en.html that version 4.2.1 will be working for your device Zire 72.

  • I need help getting this program to work.

    K. I don't pay much attention in my AP Comp Science Class.. but my teacher said if i can get this program to work i get an a for the semester... The program is Metrowerks Codewarrior IDE.. we are running it on windows 98 i think. She said she can't get it to compile.. so i guess it just needs to be able to input simple java programs (i.e. loops, just the regular crap) and compile them and run them...i have no clue what is wrong with it.. it could just need a patch...or we may just be going about it the wrong way...any help would be SUPER appreciated...

    K. I don't pay much attention in my AP Comp Science
    Class.. but my teacher said if i can get this programYou better did.
    to work i get an a for the semester... The program is
    Metrowerks Codewarrior IDE.. we are running it on
    windows 98 i think. She said she can't get it toAtleast be sure of the OS.
    compile.. so i guess it just needs to be able to
    input simple java programs (i.e. loops, just the
    regular crap) and compile them and run them...i have
    no clue what is wrong with it.. it could just need aEven we don't.
    patch...or we may just be going about it the wrong
    way...any help would be SUPER appreciated...Nothing in your thread really speaks of the problem. And since you mentioned homework, there's hardly anyone to be interested in that.
    Regards
    ***Annie***

  • I need help on this program..

    import java.util.*;
    public class D3
    private static int[] z = new int[100000];
    private static int first=z[0];
    private static int last=z[n-1];
    private static int n=100000;
    public static void main(String args[])
    Scanner input=new Scanner(System.in);
    for(int i=0;i<z.length;i++)
    z=2*i;
    int seqSearch(z;50000;n); //method call 4 key where key=mid
    int binSearch(z;first;last;50000);
    int seqSearch(z;35467;n); //method call 4 key where key in the left half
    int binSearch(z;first;last;35467);
    int seqSearch(z;89703;n); //method call 4 key where key in the right half
    int binSearch(z;first;last;89703);
    public int seqSearch(int z[];int key;int n)
    long start = System.currentTimeMillis();
    int count=0;
    int ans=-1;
    for(int i=0;i<n;i++)
    if z=key
    count++
    {ans=i
    break;}
    return ans;
    long elapsed = System.currentTimeMillis() - start;
    System.out.print("Execution Time:" + elapsed);
    System.out.print("# of Basic Operations:" + count);
    public int binSearch(int z[];int first;int last;int key)
    long start = System.currentTimeMillis();
    int count=0;
    if(last><first){
    count++;
    index=-1;
    else
    count++;
    int mid=(first+last)/2
    if(ket=z[mid]{
    index=mid;
    else
    if(key><z[mid]){
    index = binSearch(z[];first;mid-1;key);
    else
    index=binSearch(z[];mid+1;last;key);
    return index;
    long elapsed = System.currentTimeMillis() - start;
    System.out.print("Execution Time:" + elapsed);
    System.out.print("# of Basic Operations:" + count);
    if anyone could please tell me whats wrong with my code i'd be greatful...the program is supposed to perform binary and sequential search on a sorted array of 100000 numbers.once on an item in the middle of the array once on the right side of it and once on the left side...i also need to count the number of basic operations for the same number in both sequential and binary to see whats better.and i need to check the time...i think the method call is wrong,not sure though...plz i need help.its not compiling and i dont know why..

    Just add new messages to a thread you've already created. Don't create a new thread each time.
    Anyway, look. This is wrong:int seqSearch(z;50000;n); //method call 4 key where key=midfor two reasons. The first is that leading "int"; it doesn't mean anything here. "int" is used to declare an integer variable, but you're not declaring a variable here, you're invoking a method. The second problem is that you're using semicolons to separate arguments in the method call, but actually commas are correct. You probably want something more like this:
    int result;
    result = seqSearch(z, 50000, n);  //method call 4 key where key=mid.
    Some more problems with your code: you're calling non-static methods in a static context (the main method is static and seqSearch isn't). You're also using "n" before you declare it, which is probably a problem.
    And this makes no sense:z=2*i;because you've declared z to be an array; you can't use the multiplication operator on an array. It's not clear really what you're trying to accomplish there.
    Here's what I want you to do. Take your code and completely remove the binSearch method. Just rip it out. Then in your main() method, take out all references to the binSearch method, and all references except for the first one of the seqSearch method. Fix the things I mentioned above.
    Then try to compile what you have. It won't compile. You will get error messages. That's OK. Just fix them and move on. If you don't understand an error message, ask on these forums (DON'T CROSSPOST), quoting the full error message and the relevant lines of code.
    After a couple hours, you'll fix the syntactical bugs, and your program will compile. Then you'll find that it compiles but the program doesn't work right. That's also OK. This is how computer programming works. It's part of the process. Don't panic. At that point, you can start trying to fix the program so it does what it's supposed to. Eventually you'll get it to work.
    Then, and only then add more invocations of the seqSearch method. They won't all work, probably. You'll find more bugs. That's OK. Just repeat the process of fixing them.
    When you've fixed those bugs, then, and only then, add the binSearch method. Repeat the process of fixing syntax and hunting down and fixing bugs.
    Then your program will work.

  • New to Java and need help with this program..please!

    I'd really appreciate any helpful comments about this program assignment that I have to turn in a week from Friday. I'm taking a class one night a week and completely new to Java. I'd ask my professor for help, but we can't call him during the week and he never answers e-mails. He didn't tell us how to call from other classes yet, and I just can't get the darn thing to do what I want it to do!
    The assignment requirements are:
    1. Change a card game application that draws two cards
    and the higher card wins, to a Blackjack application
    2. Include a new class called Hand
    3. The Hand class should record the number of draws
    4. The application should prompt for a number of draws
    5. The game is played against the Dealer
    6. The dealer always draws a card if the dealer's hand total is <= 17
    7. Prompt the player after each hand if he wants to quit
    8. Display the total games won by the dealer and total and the total games wond by the player after each hand
    9. Display all of the dealer's and player's cards at the
    end of each hand
    10. Player has the option of drawing an additional card after the first two cards
    11. The Ace can have a value of 11 or 1
    (Even though it's not called for in the requirements, I would like to be able to let the Ace have a value of 1 or an 11)
    The following is my code with some comments about a few things that are driving me nuts:
    import java.util.*;
    import javax.swing.*;
    import java.text.*;
    public class CardDeck
    public CardDeck()
    deck = new Card[52];
    fill();
    shuffle();
    public void fill()
    int i;
    int j;
    for (i = 1; i <= 13; i++)
    for (j = 1; j <= 4; j++)
    deck[4 * (i - 1) + j - 1] = new Card(i, j);
    cards = 52;
    public void shuffle()
    int next;
    for (next = 0; next < cards - 1; next++)
    int rand = (int)(Math.random()*(next+1));
    Card temp = deck[next];
    deck[next] = deck[rand];
    deck[rand] = temp;
    public final Card draw()
    if (cards == 0)
    return null;
    cards--;
    return deck[cards];
    public int changeValue()
    int val = 0;
    boolean ace = false;
    int cds;
    for (int i = 0; i < cards; i++)
    if (cardValue > 10)
    cardValue = 10;
    if (cardValue ==1)     {
    ace = true;
    val = val + cardValue;
    if ( ace = true && val + 10 <= 21 )
    val = val + 10;
    return val;
    public static void main(String[] args)
    CardDeck d = new CardDeck();
    int x = 3;
    int i;
    int wins = 1;
    int playerTotal = 1;
    do {
    Card dealer = (d.draw());
    /**I've tried everything I can think of to call the ChangeValue() method after I draw the card, but nothing is working for me.**/
    System.out.println("Dealer draws: " + dealer);
    do {
    dealer = (d.draw());
    System.out.println(" " + dealer);
    }while (dealer.rank() <= 17);
    Card mine = d.draw();
    System.out.println("\t\t\t\t Player draws: "
    + mine);
    mine = d.draw();
    System.out.println("\t\t\t\t\t\t" + mine);
    do{
    String input = JOptionPane.showInputDialog
    ("Would you like a card? ");
    if(input.equalsIgnoreCase("yes"))
         mine = d.draw();
    System.out.println("\t\t\t\t\t\t" + mine);
         playerTotal++;
         else if(input.equalsIgnoreCase("no"))
    System.out.println("\t\t\t\t Player stands");
         else
    System.out.println("\t\tInvalid input.
    Please try again.");
    I don't know how to go about making and calling a method or class that will combine the total cards delt to the player and the total cards delt to the dealer. The rank() method only seems to give me the last cards drawn to compare with when I try to do the tests.**/
    if ((dealer.rank() > mine.rank())
    && (dealer.rank() <= 21)
    || (mine.rank() > 21)
    && (dealer.rank() < 22)
    || ((dealer.rank() == 21)
    && (mine.rank() == 21))
    || ((mine.rank() > 21)
    && (dealer.rank() <= 21)))
    System.out.println("Dealer wins");
    wins++;
         else
    System.out.println("I win!");
    break;
    } while (playerTotal <= 1);
    String stop = JOptionPane.showInputDialog
    ("Would you like to play again? ");
    if (stop.equalsIgnoreCase("no"))
    break;
    if (rounds == 5)
    System.out.println("Player wins " +
    (CardDeck.rounds - wins) + "rounds");
    } while (rounds <= 5);
    private Card[] deck;
    private int cards;
    public static int rounds = 1;
    public int cardValue;
    /**When I try to compile this nested class, I get an error message saying I need a brace here and at the end of the program. I don't know if any of this code would work because I've tried adding braces and still can't compile it.**/
    class Hand()
    static int r = 1;
    public Hand() { CardDeck.rounds = r; }
    public int getRounds() { return r++; }
    final class Card
    public static final int ACE = 1;
    public static final int JACK = 11;
    public static final int QUEEN = 12;
    public static final int KING = 13;
    public static final int CLUBS = 1;
    public static final int DIAMONDS = 2;
    public static final int HEARTS = 3;
    public static final int SPADES = 4;
    public Card(int v, int s)
    value = v;
    suit = s;
    public int getValue() { return value; }
    public int getSuit() { return suit;  }
    public int rank()
    if (value == 1)
    return 4 * 13 + suit;
    else
    return 4 * (value - 1) + suit;
    /**This works, but I'm confused. How is this method called? Does it call itself?**/
    public String toString()
    String v;
    String s;
    if (value == ACE)
    v = "Ace";
    else if (value == JACK)
    v = "Jack";
    else if (value == QUEEN)
    v = "Queen";
    else if (value == KING)
    v = "King";
    else
    v = String.valueOf(value);
    if (suit == DIAMONDS)
    s = "Diamonds";
    else if (suit == HEARTS)
    s = "Hearts";
    else if (suit == SPADES)
    s = "Spades";
    else
    s = "Clubs";
    return v + " of " + s;
    private int value; //Value is an integer, so how can a
    private int suit; //string be assigned to an integer?
    }

    Thank you so much for offering to help me with this Jamie! When I tried to call change value using:
    Card dealer = (d.changeValue());
    I get an error message saying:
    Incompatible types found: int
    required: Card
    I had my weekly class last night and the professor cleared up a few things for me, but I've not had time to make all of the necessary changes. I did find out how toString worked, so that's one question out of the way, and he gave us a lot of information for adding another class to generate random numbers.
    Again, thank you so much. I really want to learn this but I'm feeling so stupid right now. Any help you can give me about the above error message would be appreciated.

  • I need help with this program ( Calculating Pi using random numbers)

    hi
    please understand that I am not trying to ask anymore to do this hw for me. I am new to java and working on the assignment. below is the specification of this program:
    Calculate PI using Random Numbers
    In geometry the ratio of the circumference of a circle to its diameter is known as �. The value of � can be estimated from an infinite series of the form:
    � / 4 = 1 - (1/3) + (1/5) - (1/7) + (1/9) - (1/11) + ...
    There is another novel approach to calculate �. Imagine that you have a dart board that is 2 units square. It inscribes a circle of unit radius. The center of the circle coincides with the center of the square. Now imagine that you throw darts at that dart board randomly. Then the ratio of the number of darts that fall within the circle to the total number of darts thrown is the same as the ratio of the area of the circle to the area of the square dart board. The area of a circle with unit radius is just � square unit. The area of the dart board is 4 square units. The ratio of the area of the circle to the area of the square is � / 4.
    To simuluate the throwing of darts we will use a random number generator. The Math class has a random() method that can be used. This method returns random numbers between 0.0 (inclusive) to 1.0 (exclusive). There is an even better random number generator that is provided the Random class. We will first create a Random object called randomGen. This random number generator needs a seed to get started. We will read the time from the System clock and use that as our seed.
    Random randomGen = new Random ( System.currentTimeMillis() );
    Imagine that the square dart board has a coordinate system attached to it. The upper right corner has coordinates ( 1.0, 1.0) and the lower left corner has coordinates ( -1.0, -1.0 ). It has sides that are 2 units long and its center (as well as the center of the inscribed circle) is at the origin.
    A random point inside the dart board can be specified by its x and y coordinates. These values are generated using the random number generator. There is a method nextDouble() that will return a double between 0.0 (inclusive) and 1.0 (exclusive). But we need random numbers between -1.0 and +1.0. The way we achieve that is:
    double xPos = (randomGen.nextDouble()) * 2 - 1.0;
    double yPos = (randomGen.nextDouble()) * 2 - 1.0;
    To determine if a point is inside the circle its distance from the center of the circle must be less than the radius of the circle. The distance of a point with coordinates ( xPos, yPos ) from the center is Math.sqrt ( xPos * xPos + yPos * yPos ). The radius of the circle is 1 unit.
    The class that you will be writing will be called CalculatePI. It will have the following structure:
    import java.util.*;
    public class CalculatePI
    public static boolean isInside ( double xPos, double yPos )
    public static double computePI ( int numThrows )
    public static void main ( String[] args )
    In your method main() you want to experiment and see if the accuracy of PI increases with the number of throws on the dartboard. You will compare your result with the value given by Math.PI. The quantity Difference in the output is your calculated value of PI minus Math.PI. Use the following number of throws to run your experiment - 100, 1000, 10,000, and 100,000. You will call the method computePI() with these numbers as input parameters. Your output will be of the following form:
    Computation of PI using Random Numbers
    Number of throws = 100, Computed PI = ..., Difference = ...
    Number of throws = 1000, Computed PI = ..., Difference = ...
    Number of throws = 10000, Computed PI = ..., Difference = ...
    Number of throws = 100000, Computed PI = ..., Difference = ...
    * Difference = Computed PI - Math.PI
    In the method computePI() you will simulate the throw of a dart by generating random numbers for the x and y coordinates. You will call the method isInside() to determine if the point is inside the circle or not. This you will do as many times as specified by the number of throws. You will keep a count of the number of times a dart landed inside the circle. That figure divided by the total number of throws is the ratio � / 4. The method computePI() will return the computed value of PI.
    and below is what i have so far:
    import java.util.*;
    public class CalculatePI
      public static boolean isInside ( double xPos, double yPos )
         double distance = Math.sqrt( xPos * xPos + yPos * yPos );        
      public static double computePI ( int numThrows )
        Random randomGen = new Random ( System.currentTimeMillis() );
        double xPos = (randomGen.nextDouble()) * 2 - 1.0;
        double yPos = (randomGen.nextDouble()) * 2 - 1.0;
        int hits = 0;
        int darts = 0;
        int i = 0;
        int areaSquare = 4 ;
        while (i <= numThrows)
            if (distance< 1)
                hits = hits + 1;
            if (distance <= areaSquare)
                darts = darts + 1;
            double PI = 4 * ( hits / darts );       
            i = i+1;
      public static void main ( String[] args )
        Scanner sc = new Scanner (System.in);
        System.out.print ("Enter number of throws:");
        int numThrows = sc.nextInt();
        double Difference = PI - Math.PI;
        System.out.println ("Number of throws = " + numThrows + ", Computed PI = " + PI + ", Difference = " + difference );       
    }when I tried to compile it says "cannot find variable 'distance' " in the while loop. but i thought i already declare that variable in the above method. Please give me some ideas to solve this problem and please check my program to see if there is any other mistakes.
    Thanks a lot.

    You've declared a local variable, distance, in the method isInside(). The scope of this variable is limited to the method in which it is declared. There is no declaration for distance in computePI() and that is why the compiler gives you an error.
    I won't check your entire program but I did notice that isInside() is declared to be a boolean method but doesn't return anything, let alone a boolean value. In fact, it doesn't even compute a boolean value.

  • I need Help for that program

    i do aprogram for sample calculator by Java there it , i Hope if u have any sugesst say to me Or if u have a program for that.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Z extends Applet implements ActionListener {
         int n4=0;
         StringBuffer E;
         Character x;
         String s;
         TextField T1;
         public void init(){
              T1=new TextField(20);
              this.add(T1);
         Button a=new Button("2");
         this.add(a);
         a.setActionCommand("2");
         a.addActionListener(this);
         Button b=new Button("3");
         b.setActionCommand("3");
         this.add(b);
         b.addActionListener(this);
         Button d=new Button("-");
         this.add(d);
         d.setActionCommand("-");
         d.addActionListener(this);
              Button f=new Button("+");
         this.add(f);
         f.setActionCommand("+");
         f.addActionListener(this);
    Button c=new Button("=");
         this.add(c);
    c.setActionCommand("+");
    c.addActionListener(this);}
    public void actionPerformed(ActionEvent y){
         s=(y.getActionCommand());
         E=new StringBuffer();
                   x= new Character (s.charAt(0));
         E.append(x.charValue());
              if(E.length() ==3){
                   Character n=new Character(E.charAt(0));
                        Character m=new Character(E.charAt(2));
                   int n1=Integer.parseInt(n.toString());
                   int n2=Integer.parseInt(m.toString());
              if(E.charAt(1)=='+'){
                   n4=n1+n2;}
                   if(E.charAt(1)=='-'){
                   n4=n1-n2;}
                   if(E.charAt(1)=='*'){
                   n4=n1*n2;}
                   if(E.charAt(1)=='/'){
                   n4=n1/n2;}
                   if(s=="="){
                   T1.setText(String.valueOf(n4));
         

    the program is used for do acalculature, i want to know ,why he donot work? .The idea of that program it
    When u click in any number(button) the action performed get that number , and store it in StringBuffer which that stringbuffer enabel me to store three things(the first number, the sign which be *or+, and the secand number)
    and then put the result in variable and then put the result as aString in Text Field.
    I hope u can understand me now and help me for that program, If u donot understand me ,Please Sugesst to me how to do the calculature program.thanks
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Z extends Applet implements ActionListener {
         int n4=0;
         StringBuffer E;
         Character x;
         String s;
         TextField T1;
         public void init(){
              T1=new TextField(20);
              this.add(T1);
         Button a=new Button("2");
         this.add(a);
         a.setActionCommand("2");
         a.addActionListener(this);
         Button b=new Button("3");
         b.setActionCommand("3");
         this.add(b);
         b.addActionListener(this);
         Button d=new Button("-");
         this.add(d);
         d.setActionCommand("-");
         d.addActionListener(this);
              Button f=new Button("+");
         this.add(f);
         f.addActionListener(this);
    Button c=new Button("=");
         this.add(c);
         c.setActionCommand("=");
    c.addActionListener(this);
    public void actionPerformed(ActionEvent y){
         s=(y.getActionCommand());
         E=new StringBuffer();
                   x= new Character (s.charAt(0));
         E.append(x.charValue());
              if(E.length() ==3){
                   Character n=new Character(E.charAt(0));
                        Character m=new Character(E.charAt(2));
                   int n1=Integer.parseInt(n.toString());
                   int n2=Integer.parseInt(m.toString());
              if(E.charAt(1)=='+'){
                   n4=n1+n2;}
                   if(E.charAt(1)=='-'){
                   n4=n1-n2;}
                   if(E.charAt(1)=='*'){
                   n4=n1*n2;}
                   if(E.charAt(1)=='/'){
                   n4=n1/n2;}
                   if(s=="="){
                   T1.setText(String.valueOf(n4));
         

  • RV110W - trying to set up 2 VLANS - are there docs / help for this?

    I am trying to set up an RV110W router with 2 VLANs - 1 for guests to the office to just have internet access via wireless and another for employees to be able to access the LAN and internet wirelessly. I have not done anything with VLANs before, so please bear with me.
    I thought this would be simple, but banging my head against the wall with all the terms in the docs:
    http://www.cisco.com/en/US/docs/routers/csbr/rv110w/administration/guide/rv110w_admin.pdf
    port 1 is connected to a wired LAN / unmanaged switch with office PCs. So these machines / nothing on this subnet tag the packets before they get to the router.  This subnet is using 10.10.1.0/24
    Port 2 is connected to an Engenius EAP 300, a wireless access point that can broadcast SSIDs and tie each SSID to a different VLAN.
    SSID1 is called Private and is set to be VLAN 1. There's encryption on this SSID - only office staff would be able to log on.
    SSID2 is called public and is set to be VLAN 10.  There's no encryption on this SSID.
    I know - the router also does this, but where the router is vs. where the wireless is needed, we need to have the Engenius at that remote location.
    I have the RV110W set to give out 10.10.1.0/24 IPs when you connect to the SSID1 / VLAN1
    And it gives out 10.10.10.0/24 IPs when you connect to the public SSID / VLAN10.
    Both get on the internet fine.  The only issue is how to set the VLAN membership for each port / and any other settings so that the wireless devices on VLAN 1 can get to the LAN devices on Port 1.  (and the public / vlan 10 devices on the wireless network to NOT get to the devices on port 1, but i think that's working.
    I played with tagged / untagged / excluded, for the port membership, but either the wireless VLAN 1 devices get blocked from even the web (when port 2 is set to untagged, since they ARE tagged VLAN1) or they can't get to port 1 when set to tagged, since the port 1 devices are all untagged and the reply packets get blocked?
    the doc for this unit talks about inter-vlan routing but doesn't explain what that is.  THe wireless isolation should be turned on for vlan 10, right? We don't want guests to be able to access other guest's machines?
    I saw on page 71 on how to set up the guest network, but that's using the wireless built into the box, not a wireless access point.
    Overall, what I want is:
    VLAN 1: port 2 (with tagged VLAN1 packets) and port 1 (with untagged packets) can pass data between each other and access the internet
    VLAN10: port 2 with tagged VLAN10 packets can only get to the internet.
    Is that doable?
    How?

    thanks.  Still not working
    For the vlan membership page
    when set like this:
               port1         port 2
    vlan1     untagged    untagged
    vlan10  excluded     tagged
    connecting to the vlan1 wireless SSID on port 2, I can't even get an IP address from the router (the dhcp request can't even come through port 2 because it's saying vlan1 packets have to be untagged?
    connecting to the vlan 10 wireless SSID on port 2 gets a DHCP address and can only get to the web, so that's good.
    If I change the membership to:
                      port1 port 2
    vlan1 untagged  tagged
    vlan10 excluded tagged
    connecting to both SSIDs on port 2 will get you a dhcp address, and vlan1 devices can get into port 1, but trying to admin the wireless access device on port 2 or even pinging it, now fails -  'cause the router gatekeeper says if you want to come through port 2, your packets have to be tagged? and the packets from port 1 to port 2 are untagged?
    If I change the membership to:
                port1 port 2
    vlan1   tagged tagged
    vlan10 excluded tagged
    connecting to both SSIDs on port 2 will get you a dhcp address, but replies from the wired PC on port 1 / vlan1  vlan1 can't get back out of port 1 'cause the router gatekeeper says if you want to leave  through port 1, your packets have to be tagged? and the ping reply is coming form a device with untagged packets?  although the devices on vlan1 / port 1 CAN get on the web with their untagged packets.
    the wireless device says it supports 802.1q
    http://www.engeniustech.com/resources/EAP300_DataSheet_v2.1.pdf
    when they say port 2 / vlan 1 tagged, is it saying packets coming in FROM devices on that port have to be tagged? Or packets going TO devices on that port have to be tagged?  or both directions?
    Any advice?

  • Need help on this program

    Hi all,
    The purpose of this program is listed in here:
    // Inputs the miles driven and gallons used (both integers) for each tankful.
    // Calculates and displays miles per gallon obtained for each tankful and print
    // the combined miles per gallon obtained for all tankfuls up to this point.
    // All results should be floating point. Use Scanner and sentinel-controlled
    // repetition to obtain data from the user.
    // Exercise 4.17 MPG.java
    import java.util.Scanner;
    public class MPG
    private int milesDriven;
    private int gallonsUsed;
    private float result;
    public void setMilesDriven( int miles )
    milesDriven = miles;
    public void setGallonsUsed( int gallons )
    gallonsUsed = gallons;
    public String getMilesDriven( int miles )
    return milesDriven; // error occurs here
    public String getGallonsUsed( int gallons )
    return gallonsUsed;
    public MPG( float result )
    result = gallons * miles;
    System.out.printf( result);
    I try to compile this program, but the error I get is "incompatible types-found int but expected java.lang.String." How do I fix this, and how do I
    use sentinel control? If you can help me with these two things, I'd appreciate it. The sooner you can help me, the better.

    When you post code, please use[code] and [/code] tags as described in Formatting tips on the message entry page. It makes it much easier to read.
    I try to compile this program, but the error I get is
    "incompatible types-found int but expected
    java.lang.String." That means you provided an int where the program expected a string. Just like it says.
    How do I fix this,Either provide a String instead of the int, or change the code that's expecting a String to operate on an int instead.
    and how do I
    use sentinel control? II assume the instructor just wants a flag that indicates whether you're done or not. If the user enters "quit" or whatever, set that flag to true. The loop control ( while(whatever), for example) checks the flag, and either enters the loop or not.
    The sooner you can
    help me, the better.I'd advise you to keep comments like this out of your future posts. Nobody here cares about your timetable. We answer questions on our own schedule, and comments like that, and "urgent" and "asap" just annoy people.

  • Need help for this driver instalatio​n

    I need help!
    for hp 2000-2110TU ,
    i installed the memory card reader driver but the message is displayed like install your memory card driver, what have to do now..?

    Is that a USB memory card reader that you have connected. 
    **Click the KUDOS star on left to say Thanks**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.
    Thank You,
    AntonyG1
    Although I am an HP employee, I am speaking for myself and not for HP

  • Need help for Java Programming asap plzzzzzzzzzzzzz

    Here is the work: (Im writing it coz I wasn't able to attach it)
    Introduction
    In geometry, a straight line is the shortest distance between two points.
    A line may be characterised by its end points and its length.
    A line connects the points P1 and P2.
    The point P1 has coordinates {X1,Y1}.
    The point P2 has coordinates {X2,Y2}.
    The length of the line joining P1 and P2 is given by the equation:
    { (X2 - X1)2 + (Y2 - Y1)2 }1/2
    Those of you who are familiar with geometry will recognise the equation as being the well known Pythagoras equation for the hypotenuse of right angled triangles.
    Requirements
    Develop a class specification for the class Point.
    Write a short test program and test plan for this class.
    For example:
    //pointTest.java
    main(...)
    Point P1;
    P1.create(24,16); // create a point with coordinates {24,16}
    P1.display(); // display the {X,Y} coordinates of P1
    Develop a class specification for the class Line.
    Write a short test program and test plan for this class.
    For example:
    //lineTest.java
    main(...)
    Point P1 = new Point();
    P1.create(24,16); // create a point with coordinates {24,16}
    Point P2 = new Point();
    P2.create(33,42); // create a point with coordinates {33,42}
    Line L1 = new Line();
    L1.create(P1,P2); // create a line using points P1 and P2
    System.out.println( L1.length() ); // display the length of line L1
    Line L2 = new Line();
    L2.create(12,30,28,16); // create a line using coordinates {12,30}, {28,16}
    L2.display(); // display the coordinates of both points and the length of the line
    Application
    We wish to determine the length of the boundary of any regular or irregular polygon .
    The polygon may have up to 6 sides.
    The user should be prompted to enter the number of sides and the coordinates of each vertex point.
    The program should then calculate and display the total length of the boundary.
    You should write an application to implement this using your Point and Line classes.
    What I should have at the end
    The following:
    ? A listing of the files Point.java, the class test program and results.
    ? A listing of the files Line.java, the class test program and results.
    ? The application program and results.
    Note 1: All code must be written in java.

    Point P1 = new Point();
    P1.create(24,16); // create a point with coordinates {24,16}That's a terrible idea. If that was actually in your requirements, then whoever wrote it should stop teaching Java right now.
    We have constructors to initialize objects with sensible, meaningful values. Creating a new Point object without any values and then calling a "create()" method to set the values is a pretty stupid approach. Not only does it ignore the usefulness of a constructor, it also ignores the convention that methods called "create" should actually create something (and not just set values).

  • Need help for java program

    Hi,
    I need help with my web application. When i tried to run it using
    localhost:8080
    it's giving me error that
    signup.do file is not available.
    can someone tell me what could be wrong with my code?
    I want to know what is .do file and what needs to do to have remove the error
    I have also used struts config file.
    Please help me.
    Message was edited by:
    star4588

    See struts documentation here http://struts.apache.org/1.2.9/userGuide/building_controller.html#action_mapping_example
    you should have something like that :
    <action-mappings>
            <action
                path="/signup"
                type="org.apache.struts.webapp.example.SignupAction"
                name="signupForm"
                scope="request"
                input="/signup.jsp"
                unknown="false"
                validate="true" />
        </action-mappings>in your struts-config.xml.
    Hope That Helps

  • Help help help help. I just mistakenly deleted a Note from the Note App that I need.  I don't use iCloud. The only place I have the Note app is on my iPad and my iPod. What can I do? Is there any help for this?

    Help help help.
    I just deleted a note from the Notes App form my ipad3. I don't use iCloud. The only place this note was is my iPod and iPad. Is there any possible way to recover this note?????
    Thanks in advance

    Thank you sberman, yes the first thing I did was check my iPod. Instant synching works great between the iPad and iPod, so it was deleted there as well. On both devices I have my Notes account to the same account.
    I ashamedly have not synched to iTunes for ages. After I calmed down I realized that most of the info on that deleted Note I had copied and pasted from an excel file in November. I'm in the process of doing that again, and am only out the recent info.

  • Need code for this program in pl/sql

    Hi,
    was looking for a pl/sql code for the following case
    If there are two employees from the EMP table. i want all the names of the managers common to the two employees....
    to explain in detail : if employee1 and employee2 have the same manager mgr1....mgr1 should be displayed.
    else if employee 1 and employee2 have no immediate manager in common...meaning team leader of employee 1 and employee2 are different but the project managers for both the employee is same..in this case the project manager's name should be displayed......
    else in worst case when there are no managers common between these two employees.........the CEO who is at the highest level is common....then display CEO's name
    it's hierchiacal structure......
    thanks,
    Preethi

    Why PL/SQL? Why not look at if this can be done using SQL firstly? SQL is the preferred language for crunching Oracle data. Not PL/SQL.
    Think data sets.
    One method to do this in SQL would be to build a hierarchical list of managers for each employee. E.g.
    LEVEL MANAGER
    1     Jack
    2     John
    10     Dan the CEOOnce you have such a list for each employee, you can join these two lists on matching names. Then you simply need to find the matching join that has the lowest level.
    I'm sure there are other approaches. But unless you put together some test data, put together some SQLs and play around with this problem, you are not going to learn anything.
    And no, copying and pasting an answer that someone is inevitable to post in response is NOT learning anything new.
    So why not try and solve this problem yourself? Gain some new knowledge. That will only do your career well as your employer is after all expecting you to write the code to solve this problem - and not for members of this forum to supply the code for you.

  • Is there any help for this..

    Hello friends,
    I am not getting any answer from the experts of oracle. Why I don't know?
    I am asking a simple question realted to forms. I want to keep my form 'always on top' of other running application in windows for a specific requirements. How to do this?
    If anybody know, then please let me know. If YES, then how?
    If NO, then Why?
    regards,
    Praveenkumar Talla (Pune, India)

    Hello Praveenkumar,
    an answer (that I'm not sure if will fit your need) could be the following:
    open your form, look for the Window you want to keep always on top, and set the property 'Window Style' to 'Dialog box'. When it's defined as 'Document', your window stays inside the window that Forms Runtime open.
    Hope this help, although I'm not sure if this will help you.
    Best regards,
    Franklin Gongalves Jr.
    [email protected]
    Hello friends,
    I am not getting any answer from the experts of oracle. Why I don't know?
    I am asking a simple question realted to forms. I want to keep my form 'always on top' of other running application in windows for a specific requirements. How to do this?
    If anybody know, then please let me know. If YES, then how?
    If NO, then Why?
    regards,
    Praveenkumar Talla (Pune, India)

Maybe you are looking for

  • Apple TV - Internet based content

    Hi. I'm considering the Apple TV unit. I know you can login to YouTube.com to watch videos, but can you also surf the web in general? Are there plug-ins for it - for example can I play music via Pandora.com? Any help would be appreciated.

  • Datasocket 4.0 Network Client stops if Data are with Attirutes

    OS: W2000pro, VB50pro, DSServer40(370) Dear friends, I have some misterious problem with DS40. Configuration : I have one writer with DSServer 40 on one computer and several clients on the same and other computers. Problem: The Clients Data on remote

  • How to access transport logs?

    looks like somebody in our company sent confidential information outside, i've been asked to check email logs to verify if it's been done via email. any tips/suggestions would be highly appreciated. thank you.

  • Idvd burn/encoding problem

    When I try to burn an idvd project I keep on getting a msg reading 'Your project exceeds the maximum content duration. To burn your DVD, change the encoder setting in the Project Info window.' However when I check project info the project is way unde

  • How to use a stylus

    i just got a new touchscreen laptop and i want to use the stylus for drawing and altering photos in photoshop. please hwlp