Need help with class object? Please somoen

hey guys,
It's been few days since i'm working on making a small bingogame program but i'm getting stuck frequantly.
I've different classes, in the main class i'm asking the user to input number of players who would like to play then i'm asking the player's name and how many bingoCards each player wants.
I'm stroing all that info in a BingoPlayer class's array object. But for some reason when i get out from the loop and try to retrive the info from that array it only gives me the last input entry (player's name & number of cards) at any index of the array.
Can please someone tell me how i can store the given information for each player in that object array on different indices of the array?
I'm providing the code where i've the problems:
public class BingoGame
    public static BingoPlayer players[] = new BingoPlayer[5];
    public static void main() throws IOException {
        int numPlayers = 0;
        int numCards [] = new int [5];
        String name [] = new String[4];
        BufferedReader input = new BufferedReader (new InputStreamReader(System.in)); //allows input
// ask for the number players who wants to play
        System.out.print("Please enter the number of players in this game (2-5): ");
        numPlayers = Integer.parseInt(input.readLine());
// make sure the entered value is within range
        while (numPlayers < 2 || numPlayers > 5) {
            System.out.println("Invalid number of players ");
            System.out.print("Please enter the number of players in this game (2-5): ");
            numPlayers = Integer.parseInt(input.readLine());
        System.out.println();
//ask for the names and numebr of cards for entered number of players
// and make sure the number of cards are within the range,
//and assign the players that many cards using the BingoPlayer object 
        for (int i = 1; i <= numPlayers; i++) {
            System.out.print("Please enter name of player " + i + " : ");
            name[i] = input.readLine();
            System.out.println();
            System.out.print("Please enter the number of cards (1-5) for player " + i + " : ");
            numCards[i] = Integer.parseInt(input.readLine());
            while (numCards[i] < 1 || numCards[i] > 5) {
                System.out.println("Invalid number of cards for the player " + i);
                System.out.print("Please enter the number of cards (1-5) for player " + i + " : ");
                numCards[i] = Integer.parseInt(input.readLine());
            System.out.println();
            players[i] = new BingoPlayer(name, numCards[i]);
* here it only prints out the information for the last player, instead it should return the information for both of the player
for (int k = 1; k <= numPlayers; k ++) {
System.out.println(players[k]);
//players[k].genCards();
for example if i enter 2 players:
Player1: name: Jami, number of cards 1
Player2: name: Joey, number of cards 2
in the last loop it just prints out :"Joey, 2" 2 times instead of printing out: "Jami, 1" & "Joey, 2"
Please someone help! i really need to complete this within 2 days. Thanks in advance

Without seeing BingoPlayer's implementation, all it
would be would be a guess.
My guess: The name and numCards members of that class
are declared as static, so all instances share the
same values.Thanks it worked, declaring them static was the main probelm..thank you very much

Similar Messages

  • Need help with classes

    I''ve just started out with Java and I need help with my latest program.
    The program looks someting like this:
    public class MultiServer {
       public static void main(Straing[] args) {
          ServerGUI GUI = new ServerGUI();
    public class ServerGUI extends JFrame implements ActionListener {
       private TextArea textArea;
       public ServerGUI() {
          //setting up the JFrame and stuff like that
       public void actionPerformed(ActionEvent event) {
          if(button == addButton) {
             addGUI add = new addGUI();
    public class addGUI extends JFrame implements ActionListener {
        private TextField t1 = new TextField(25);
        public addGUI() {
          //setting up the JFrame and stuff like that
       public void actionPerformed(ActionEvent event) {
          if(button == printButton) {
             textArea.append("THIS DOES NOT WORK!");
    }   The problem is as follows: I want to be able to write text in the textArea in class ServerGUI from the class addGUI, but I can't. I hope you understand what I mean.
    How is this fixed? Please help me!

    public void actionPerformed(ActionEvent event) {
          if(button == addButton) {
             addGUI add = new addGUI(textArea);
    public class addGUI extends JFrame implements ActionListener {
        private TextArea textArea;
        public addGUI(TextArea textArea) {
            this.textArea = textArea;
        }/Kaj

  • I need help with this script please ASAP

    So I need this to work properly, but when ran and the correct answer is chosen the app quits but when the wrong answer is chosen the app goes on to the next question. I need help with this ASAP, it is due tommorow. Thank you so much for the help if you can.
    The script (Sorry if it's a bit long):
    #------------Startup-------------
    display dialog "Social Studies Exchange Trviva Game by Justin Parzik" buttons {"Take the Quiz", "Cyaaaa"} default button 1
    set Lolz to (button returned of the result)
    if Lolz is "Cyaaaa" then
    killapp()
    else if Lolz is "Take the Quiz" then
              do shell script "say -v samantha Ok starting in 3…2…1…GO!"
    #------------Question 1-----------
              display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
              set A1 to (button returned of the result)
              if A1 is "Apprentices" then
                        do shell script "say -v samantha Correct Answer"
              else
                        do shell script "say -v samantha Wrong Answer"
      #----------Question 2--------
                        display dialog "Most children were taught
    to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
                        set A2 to (button returned of the result)
                        if A2 is "Bible" then
                                  do shell script "say -v samantha Correct Answer"
                        else
                                  do shell script "say -v samantha Wrong Answer"
      #------------Question 3---------
                                  display dialog "In the 1730s and 1740s, a religious movement called the_______swept through the colonies." buttons {"Glorius Revolution", "Great Awakening", "The Enlightenment"}
                                  set A3 to (button returned of the result)
                                  if A3 is "Great Awakening" then
                                            do shell script "say -v samantha Correct Answer"
                                  else
                                            do shell script "say -v samantha Wrong Answer"
      #-----------Question 4--------
                                            display dialog "_______ was
    a famous American Enlightenment figure." buttons {"Ben Franklin", "George Washington", "Jesus"}
                                            set A4 to (button returned of the result)
                                            if A4 is "Ben Franklin" then
                                                      do shell script "say -v samantha Correct Answer"
                                            else
                                                      do shell script "say -v samantha Wrong Answer"
      #----------Question 5-------
                                                      display dialog "______ ownership gave colonists political rights as well as prosperity." buttons {"Land", "Dog", "Slave"}
                                                      set A5 to (button returned of the result)
                                                      if A5 is "Land" then
                                                                do shell script "say -v samantha Correct Answer"
                                                      else
                                                                do shell script "say -v samantha Wrong Answer"
      #---------Question 6--------
                                                                display dialog "The first step toward guaranteeing these rights came in 1215. That
    year, a group of English noblemen forced King John to accept the…" buttons {"Declaration of Independence", "Magna Carta", "Constitution"}
                                                                set A6 to (button returned of the result)
                                                                if A6 is "Magna Carta" then
                                                                          do shell script "say -v samantha Correct Answer"
                                                                else
                                                                          do shell script "say -v samantha Wrong Answer"
      #----------Question 7--------
                                                                          display dialog "England's cheif lawmaking body was" buttons {"the Senate", "Parliament", "King George"}
                                                                          set A7 to (button returned of the result)
                                                                          if A7 is "Parliament" then
                                                                                    do shell script "say -v samantha Correct Answer"
                                                                          else
                                                                                    do shell script "say -v samantha Wrong Answer"
      #--------Question 8-----
                                                                                    display dialog "Pariliament decided to overthrow _______ for not respecting their rights" buttons {"King James II", "King George", "King Elizabeth"}
                                                                                    set A8 to (button returned of the result)
                                                                                    if A8 is "King James II" then
                                                                                              do shell script "say -v samantha Correct Answer"
                                                                                    else
                                                                                              do shell script "say -v samantha Wrong Answer"
      #--------Question 9------
                                                                                              display dialog "Parliament named ___ and ___ as England's new monarchs in something called ____." buttons {"William/Mary/Glorius Revolution", "Adam/Eve/Great Awakening", "Johhny/Mr.Laphalm/Burning of the hand ceremony"}
                                                                                              set A9 to (button returned of the result)
                                                                                              if A9 is "William/Mary/Glorius Revolution" then
                                                                                                        do shell script "say -v samantha Correct Answer"
                                                                                              else
                                                                                                        do shell script "say -v samantha Wrong Answer"
      #---------Question 10-----
                                                                                                        display dialog "After accepting the throne William and Mary agreed in 1689 to uphold the English Bill of _____." buttons {"Money", "Colonies", "Rights"}
                                                                                                        set A10 to (button returned of the result)
                                                                                                        if A10 is "Rights" then
                                                                                                                  do shell script "say -v samantha Correct Answer"
                                                                                                        else
                                                                                                                  do shell script "say -v samantha Wrong Answer"
      #---------Question 11------
                                                                                                                  display dialog "By the late 1600s French explorers had claimed the ___ River Valey" buttons {"Mississippi", "Ohio", "Hudson"}
                                                                                                                  set A11 to (button returned of the result)
                                                                                                                  if A11 is "Ohio" then
                                                                                                                            do shell script "say -v samantha Correct Answer"
                                                                                                                  else
                                                                                                                            do shell script "say -v samantha Wrong Answer"
      #------Question 12---------
                                                                                                                            display dialog "______ was sent to ask the French to leave 'English Land'." buttons {"Johhny Tremain", "George Washington", "Paul Revere"}
                                                                                                                            set A12 to (button returned of the result)
                                                                                                                            if A12 is "George Washington" then
                                                                                                                                      do shell script "say -v samantha Correct Answer"
                                                                                                                            else
                                                                                                                                      do shell script "say -v samantha Wrong Answer"
      #---------Question 13-------
                                                                                                                                      display dialog "_____ proposed the Albany Plan of Union" buttons {"George Washingon", "Ben Franklin", "John Hancock"}
                                                                                                                                      set A13 to (button returned of the result)
                                                                                                                                      if A13 is "Ben Franklin" then
                                                                                                                                                do shell script "say -v samantha Correct Answer"
                                                                                                                                      else
                                                                                                                                                do shell script "say -v samantha Wrong Answer"
      #--------Question 14------
                                                                                                                                                display dialog "The __________ declared that England owned all of North America east of the Mississippi" buttons {"Proclomation of England", "Treaty of Paris", "Pontiac Treaty"}
                                                                                                                                                set A14 to (button returned of the result)
                                                                                                                                                if A14 is "" then
                                                                                                                                                          do shell script "say -v samantha Correct Answer"
                                                                                                                                                else
                                                                                                                                                          do shell script "say -v samantha Wrong Answer"
      #-------Question 15-------
                                                                                                                                                          display dialog "Braddock was sent to New England so he could ______" buttons {"Command an attack against French", "Scalp the French", "Kill the colonists"}
                                                                                                                                                          set A15 to (button returned of the result)
                                                                                                                                                          if A15 is "Command an attack against French" then
                                                                                                                                                                    do shell script "say -v samantha Correct Answer"
                                                                                                                                                          else
                                                                                                                                                                    do shell script "say -v samantha Wrong Answer"
      #------TheLolQuestion-----
                                                                                                                                                                    display dialog "____ is the name of the teacher who runs this class." buttons {"Mr.White", "Mr.John", "Paul Revere"} default button 1
                                                                                                                                                                    set LOOL to (button returned of the result)
                                                                                                                                                                    if LOOL is "Mr.White" then
                                                                                                                                                                              do shell script "say -v samantha Congratulations…you…have…common…sense"
                                                                                                                                                                    else
                                                                                                                                                                              do shell script "say -v alex Do…you…have…eyes?"
                                                                                                                                                                              #------END------
                                                                                                                                                                              display dialog "I hope you enjoyed the quiz!" buttons {"I did!", "It was horrible"}
                                                                                                                                                                              set endmenu to (button returned of the result)
                                                                                                                                                                              if endmenu is "I did!" then
                                                                                                                                                                                        do shell script "say -v samantha Your awesome"
                                                                                                                                                                              else
                                                                                                                                                                                        do shell script "say -v alex Go outside and run a lap"
                                                                                                                                                                              end if
                                                                                                                                                                    end if
                                                                                                                                                          end if
                                                                                                                                                end if
                                                                                                                                      end if
                                                                                                                            end if
                                                                                                                  end if
                                                                                                        end if
                                                                                              end if
                                                                                    end if
                                                                          end if
                                                                end if
                                                      end if
                                            end if
                                  end if
                        end if
              end if
    end if

    Use code such as:
    display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
    set A1 to (button returned of the result)
    if A1 is "Apprentices" then
    do shell script "say -v samantha Correct Answer"
    else
    do shell script "say -v samantha Wrong Answer"
    return
    end if
    #----------Question 2--------
    display dialog "Most children were taught to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
    set A2 to (button returned of the result)
    if A2 is "Bible" then
    do shell script "say -v samantha Correct Answer"
    else
    do shell script "say -v samantha Wrong Answer"
    return
    end if
    (90444)

  • I would need help with the following please: I need to save some of my email on a disk. I was going to Print, then Save PDF but then I am stuck. Help please. Thanks. Elisabeth

    I would need help with saving some eamil messages to a disk to unclutter my email. How can I do this please?
    Thanks.
    Elisabeth

    Open the email and then from the File menu select Save As Rich Text Format. That'll save it to open in TextEdit. If you want a pdf then open the email and do command-p (Print) and then from the PDF drop down box lower left corner select Save as PDF.

  • Need help with Portal Themes -- Please help

    I need help with Portal Themes.  I have read every document I can find but I am having no luck.  All I want to do is change the colors for the Exceptions on one of my queries.  I have created my own Portal Theme where I have changed the colors but I do not know how to assign my newly-created Portal Theme to my query.  Can someone please give me the detailed steps on how to do this? Please help because this is driving me crazy.
    Thanks.
    Ryan

    Hi,
    Refer
    Exceptions - How to change the colors
    This may help.
    Thanks,
    JituK

  • Need help with class design

    I want to design and use one or more classes for a particular project I am working on.
    I need some advice hopefully from someone who has experience in this area. Basically,
    for this particular problem I have two database tables. I want the first class to
    represent the first database table and the second class to represent the second
    database table. An object of the first class will be created first, and then if certain
    criteria are met then an object of the second class will be created.
    Question:
    Should I use classical inheritance and let the first class inherit from the second class?
    Or should I use the containment delegation model and embed an object of the second
    class in the first class?
    ----Tables------
    For example, my first table ET_UserData looks something like this:
    ET_UserData
    (PK)UserName
    Password
    FirstName
    LastName
    My second table ET_DetailedUserData looks like this
    ET_DetailedUserData
    (FK)UserName
    WorkAddress
    WorkPhoneNumber
    CityWhereEmployed
    SocialSecurityNumber
    City
    State
    StreetAdress
    PrimaryTelephoneNumber
    AlternatePhoneNumber
    HasRegistered
    RegistrationDate
    RegistrationTime
    CreditCardNumber
    NameOfPrimaryContact
    DateOfBirth
    Weight
    EyeColor
    Height
    Member
    Here is are some pseudo classes for the two classes.
    Class UserData
    string UserName
    string FirstName
    string LastName
    Class DetailedUserData /* For a classical approach, sub class off of class UserData */
    /* UserData ThisUser --> Containment delegation model */
    string (FK)UserName
    string WorkAddress
    string WorkPhoneNumber
    string CityWhereEmployed
    string SocialSecurityNumber
    string City
    string State
    string StreetAdress
    Int PrimaryTelephoneNumber
    Int AlternatePhoneNumber
    Bool HasRegistered
    Int RegistrationDate
    Int RegistrationTime
    Int CreditCardNumber
    String NameOfPrimaryContact
    Int DateOfBirth
    Int Weight
    Int EyeColor
    Int Height
    bool Member
    }

    Thank you for your help. If you can continue to help me I would appreciate it.
    I and another developer did the database design. Pretty solid design. Plus we have all of the requirements
    which are very good too.
    Originally I wanted just one table to contain all of the data associated with a user. Instead of ET_UserData and ET_Detailed user data I wanted just one table. But I decided to break this table up into the two tables for the following reason.
    1.) This is a web application where each user logs into a web form. At a minimum, in order to use the website the session associated with each user needs the UserName, Password, First and last name.
    This is the data in the first table.
    If they choose to do more specialized functions on this website, then they will need all of the information (Attributes) that are located in the second table. In general 40% of the time all users will need information located in the second table.
    My reasoning for breaking the table into two seperate tables is that I wanted to minimize the amount of data involved in a result set, created from the sql query. The math tells me that 60% of the time most of the data in the result set will not be used.
    2.) If I create one class to represent all of the data/attributes in both tables, then my reasoning is that their will be alot of overhead in the single class because 60% of the time, a majority of the attributes are not needed and used.
    I would deeply appreciate your help with this. You seem to have great insight and advice. Please help me as I increase the duke dollars Sir.

  • Need help filling this object please!!!

    I need to fill shape 1 with a solid color. Shape 2 is what the object looks like when selected. Shape 3 is what happens when I try to fill it with color. I need it to stay within the boundaries shown on shape 1. Please help, I'm relatively new to Illustrator and cannot seem to find out what it is that is happening. I'm working in Illustrator CC.

    jbizzle,
    However I needed to redraw the object, and instead of lines I had to use rounded rectangles to create it.
    Can you reuse the outer shape that looks like part of an ellipse?
    If you can, you can start by recreating the top one as follows (Smart Guides are your friends):
    1) Select and copy the upper/outer elliptic shape to the front (Ctrl+C+F), then lock the original full shape;
    2) With the Line Segment Tool ClickDrag between the end Anchor Points of 1) (Smart Guides say anchor when you are there), then drag over the H value in the Transform palette and Ctrl+C to copy it;
    3) Click with the Ellipse Tool on the Artboard and insert the value divided by 2 for W and H, then cut it at the top and bottom Anchor Point, then delete the right half;
    4) Move the half circle on top of the lower left half circle shape as closely as possible, then select both the half circle and the outer ellipse, click the outer ellipse again and in the Align palette click Vertical Align Bottom;
    4) Create a copy of the half circle and move it up by its height, then ShiftDrag it to fit the upper right half circle shape as closely as possible;
    Now you should have the curved parts in place, and you only need the straight parts;
    5) With the Direct Selection Tool Click each pair of Anchor Points to be connected by straight segments and Ctrl+J to join them;
    Now you should have one clean path to fill. After that, you can rotate and move a copy.

  • Where to start? Need help with classes

    My question involves those classes he wants us to make. I don't really get the concept of classes, so could someone tell me what they think he wants us to do? And try to explain it to me in terms I might be able to understand. Does that mean for us to use subclasses or use separate files for each class? Or could I do either? I'm so confused :(
    Assignment: Write a program that consists of the classes listed below.
    Player Class: The Player Class consists of at least two elements -- the player name and a list of scores for
    games. The score attribute is not used in Program #3 but will be needed in Program #4. Include in the
    class appropriate accessor and mutator methods for each element in the class. You may have other
    attributes if needed.
    Team Class: The Team class consists of at least 6 elements -- the name of the team and five players from
    the Player class. Include in the class appropriate accessor and mutator methods for each element in the
    class. You may have other attributes if needed.
    Course Syllabus Page 3
    Input3 class: The Input3 class is provided for you. The Input3 class supplies data for your program. The
    Input3 class has a public method called getNextString, which returns a string with the input for your
    program, one after the other. You must use this class to get the data for your program. See Input3.java on
    WebCT to understand the class construction.
    Your program should display the roster of each team in alphabetical order by last name.
    This is the Input3 that he gave us to work with if anyone needs to see it:
    public class Input3
         private String[] input = new String[40];
         private static int StringNum = -1;
         public static final int NUMBER_OF_TEAMS = 3;
         public static final int NUMBER_OF_PLAYERS = 5;
         public Input3()
              //The first six inputs will be for the first team
              input[0] = "LAKERS";
              input[1] = "Kobe Bryant";
              input[2] = "Derek Fisher";
              input[3] = "Shaquille O'Neal";     
              input[4] = "Karl Malone";
              input[5] = "Brian Cook";
              //The next six inputs will be for the second team
              input[6] = "MAVERICKS";
              input[7] = "Antoine Walker";
              input[8] = "Dirk Nowitzki";
              input[9] = "Tony Delk";
              input[10] = "Shawn Bradley";
              input[11] = "Travis Best";
              //The next six inputs will be for the third team
              input[12] = "KNICKS";
              input[13] = "Mike Sweetney";
              input[14] = "Allan Houston";
              input[15] = "Howard Eisley";
              input[16] = "Kurt Thomas";
              input[17] = "Shanon Anderson";
         //This method returns the strings one after the other.
         public String getNextString()
              StringNum++;
              return input[StringNum];
    }<br>
    <br>
    <br>
    Thanks

    You could put the classes in separate files, but it's not necessary. They wouldn't be called 'subclasses' here, as that word is specific to inheritance, which you don't need here. Here's an example of using multiple classes:
    public class MainClass {
        public static void main(String [] args) {
         OtherClass1 oc1 = new OtherClass1(3);
         OtherClass2 oc2 = new OtherClass2("hello");
         System.out.println("" + oc1.getInt());
         System.out.println(oc2.getString());
    class OtherClass1 {
        int someInt;
        public OtherClass1(int i) {
            someInt = i;
        public getInt() {
         return someInt;
    class OtherClass2 {
        String someString;
        public OtherClass2(String s) {
            someString = s;
        public getString() {
            return someString;
    }and like BDLH said above, it's preferred to put them in separate files. Just make sure the file name is EXACTLY the same as the class name, followed by .java

  • Need help with case structures- please help :)

    Hey all.
    I'm currently trying to program a infrared furnace. I'm setting a temperature, subtracted my set temperature from the actual temperature (thermocouple hooked up to SCB-68), and voltage is being sent to the controller of the furnace accordingly. However, I need to hold the set temperature for a certain amount of time. I need help programming this: when the VI reads the set temperature from the thermocouple, it results in a timer running down. When the timer runs down to 0, the While Loop ends. I'm thinking case structures is most appropriate, but if you have a better suggestion, please let me know.
    Thanks

    You should probably implement a state machine.
    The state machine would keep track of the temperature and making ajustments on a timely basis.
    There is a template of a state machine is you select under the File menu > New > From Template.
    You can also look under Help > Find Example > and do a search for state machine.
    There are lots of state machine examples on this forum, some of which may be quite useful.
    RayR

  • Help with Classes, Objects and their relationship.

    Alright, I've got this assignment from a computer science class that won't stop annoying me and I need some help. This is the complete assignment: http://zebra0.com/Tarraga/CS103/Project4.php
    What I'm having issues with is the course specifications. It says:
    ? Create a course class. It will contain the course name, 5 Student objects, the number of Students, etc. It will contain an addStudent(), printRoll() and average() methods. You may add methods as needed. The average method computes the average of all students test score averages.
    I'm not sure what my instructor means by 5 student objects. I'm assuming that addStudent() would create a new student() object (from the class which I've already created here: http://zebra0.com/Tarraga/CS103/studentP4.php) and printRoll() will print the existing objects, average() I think I know.
    So...wth am I supposed to create 5 student objects for? Or what are they referring to? I'd assume that the student objects are created only when the user inputs the student data, not internally.
    My question is what I'm assuming to be extremely newb-ish, and to be honest I am a complete newbie, but if anyone can help please do so.
    Edit: Another question I had regarded my student class would be, do I need to write getters/setters for every value in there? My instructor wouldn't stop raving about how we need getters/setters, but at this point I'm not exactly sure what they do.

    to didittoday:
    You could say that, yes. But honestly...I've been paying plenty of attention. What I've learned so far about an object in Java is the following:
    An object in programming is like an object in real life. It makes up the program. Just like a wheel is part(object) of a card, an object is part of the program.
    That's what my teacher has taught me, with pictures even. I've written about two GUI and one non GUI projects so far that I had to look to the book to actually finish. And that's her general answer to all our questions, "read the book!" She doesn't ever take time from showing us her precious powerpoints to actually teach us. And not once has she actually given us examples of coding. She instead directs us to the programs in our book which may or may not be of relevance.
    And all the tutors who could actually help me aren't on campus. If you'd like to redirect me to a link that may hold useful (and RELEVANT) information, please do so.
    Also: I do understand that a student object would hold student information (I.E.:
    public student (String firstname, String lastname, double score1, double score2, double score3, double score4)but I don't understand why 5 student objects should be created in the other class...is it that they have to be initialized and then once the user inputs the information, they are updated? I'm grasping at straws here.
    Edited by: Valkyrio on Mar 5, 2008 3:28 PM

  • Need help with If statement Please

    Hi guys,
    This is my first time posting and sorry if for some reason i post incorrectly.
    I am having trouble figuring out what I am doing with my if Statement and why the compiler is giving me an error which says 'cannot find symbol';
    Just incase you need to see the code here it is. And please any pointers would help me get back on track. And please dont laugh at the novice code i just started^^;
    import java.util.*;
    import java.text.*;
    public class Student
         public static void main(String[]args)
         Scanner scan=new Scanner(System.in);
         double std1, std2, std3, num1, num2, num3, num4;
         String a, answer1, name1;
    System.out.println("Welcome to _____ program, press any button to continue: ")
    a=scan.nextLine();
    System.out.println("Good, would you like to enter a grade for a student(y/n)?");
    answer1=scan.nextLine();
    if (answer1 == y)
         System.out.println("Please enter the students name ");
                             name1=scan.nextLine();
                             System.out.println("Please label the test number ");
                             num1=scan.nextDouble();
                             System.out.println("Please enter the grade, "+name1+" recieved");
    std1=scan.nextDouble();
    if (answer1==n)
         System.out.println("Thank you for trying my program ");
    else
    System.out.println("It's obvious you couldn't follow a simple direction good bye ");

    Thanks Flounder,
    I'll keep in mind to edit the code the way you told me too.
    As far as the code goes, what do you mean 'y' is not a string and should be a variable. All I'm trying to do is give a true false statement.
    For example
    if (input==y)
    System.out.println("________");
    And in my code it gives an error stating that y is a variable.
    I dont understand why.
    Thanks much for all your replies.

  • I need help with my setup Please !!! 2800+ athlon xp

    hi all .......... great forum here.....!!!
    I am having probs with my new setup and I am at a wits end of what to do so i'll explain my problem.
    I have just bought a AMD athlon 2800+ cpu for my mobo (KT3 ultra 6830e v.1.0)
    and I am unable to run the chip at correct speed??
    The bios wont boot the computer if I try to set the fsb for cpu at 166 ?? Am I correct in thinking that a 2800+ Athlon needs to be run at 166fsb to get the 333fsb setting?
    I am currently running it at 133fsb and it is registering it as a AMD 2200+ chip ???
    I am quite new to playing about with my bios but at the moment it is set at defaults on everything because i had to reset the cmos jumper about 8 times last night after trying different settings, in the end i gave up and thought i'd ask u guys for help???? Please !!!
    I spoke to the shop i bought the chip from and we got talking about that when i set the fsb for chip to 166 it changed the ram settings to host clock + 66 (host clock was set at 100mhz) thus trying to make my 2100 ram(266) run at 2700(333) specs ?
    Is this the problem why my computer wont boot when it is set to 166 fsb cuz it is asking the ram to be 333ddr when it isn't???
    Is my problem going to be solved if i purchase some 2700 ram ?? if so i'll be quite happy, or is my board just not capable of running this 2800+ cpu on it???
    i read up b4 i bought the cpu and i thought i was able to run this chip maybe i read wrong? any help would be greatly appreciated , oh i also flashed my bios to the most recent msi update which was 5.7 i think (AMI bios) and the flash was succesfull (LOL) very worrying!!!!
    anyway hope i have explained my problem well enough as i myself am very confused!!!!
    Thanks in advance
    Dave

    i have just had a look around the net and it looks like there are two versions of the 2600+ available one with 133/266fsb support and the other with 333fsb ???
    Do u know that if i take my 2800+ back to the shop and change it for a 2600+ cpu if i should just get a normal one(133/266fsb) or get the 333fsb version???
    as that link u posted for the mobo supported cpus only lists the 2600+ as being a 133/266fsb chip ???
    I will get some 333ddr ram as well just incase i need this to allow the 2600+ to run correctly
    Also (sorry to be a pain) but can you explain to me how to change the multipliers correctly to get full power from the chip ?? as i read that a 2600+ comes out at 1.91ghz standard , but i was reading a review where the user was told by AMD that it will run higher by changing fsb or multipliers (or both?) ???
    Do u have to set the fsb to 133 and then change the multiplier to a value to up the speed or just keep changing the fsb alone and leave the multipliers alone ????
    Hope you can help me......
    Thanks once again for your replys..
    Dave

  • Need help with class I'm trying to write for school

    Hi,I'm taking my first Java class, and we're learning how to write classes. I've got MOST of the program and class to work, but I'm still having trouble with it.
    In the class I wrote, if I delete the "getWindTempF(strAlt)" the program runs fine, other than not doing the conversion to Fahrenheit. So, I'm guessing that there's a problem with my getWindTempF method. However, it is almost exactly a duplicate of my getWindTempC method, so I can't figure out what I'm doing wrong. The errors I get when I keep the "getWindTempF(strAlt)" in the prtWindInfo method are:
    java.lang.NumberFormatException: For input string: " "
         at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         at java.lang.Integer.parseInt(Integer.java:426)
         at java.lang.Integer.parseInt(Integer.java:476)
         at NWSFD.getWindTempF(NWSFD.java:94)
         at NWSFD.prtWindInfo(NWSFD.java:162)
         at a19004.main(a19004.java:30)
    Exception in thread "main"
    ----jGRASP wedge2: exit code for process is 1.
    Again, the program and class work perfectly except for the getWindTempF. Any ideas would be greatly appreciated, and sorry for such a long post
    Here is the main program:
    import cs1.Keyboard;
    import java.text.NumberFormat;
    import java.text.SimpleDateFormat;
    import java.text.DateFormat;
    import java.util.Date;
    public class a19004
         // Instantiates the windsAloft object by using the NWSFD class
         public static void main (String[] args)
              final String FAA_FD="SAN 1405 2908+26 2911+19 2809+11 1307-09 0308-20 " +
              "032433 012543 352853";
              NWSFD windsAloft = new NWSFD(FAA_FD);     //Instantiate the NWSFD object
              System.out.println ("Winds Aloft");
              System.out.println ("as of " + windsAloft.getDate());
              System.out.println ("");
              System.out.println ("STA Alt Dir Speed TempC TempF");
              System.out.println ("");
              System.out.println (windsAloft.prtWindInfo("03"));
              System.out.println (windsAloft.prtWindInfo("06"));
              System.out.println (windsAloft.prtWindInfo("09"));
              System.out.println (windsAloft.prtWindInfo("12"));
              System.out.println (windsAloft.prtWindInfo("18"));
              System.out.println (windsAloft.prtWindInfo("24"));
              System.out.println (windsAloft.prtWindInfo("30"));
              System.out.println (windsAloft.prtWindInfo("34"));
              System.out.println (windsAloft.prtWindInfo("39"));
    And for the sake of brevity, just a part of the NWSFD class:
    import java.text.*;
    import java.util.Date;
    public class NWSFD
         // Set up variables
         private String strWea;
         // 3.a. Constructor
         public NWSFD (String strVar)
              strWea=strVar + " ";
         // 3.d.
         public String getWindTempC (String strAlt)
              String strVar;
              strVar = strWea.substring(getPos(strAlt) + 4, getPos(strAlt) + 7);
              if (strAlt.equals("03"))
                   strVar = strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 5);
              if (strAlt.equals("30"))
                   strVar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strAlt.equals("34"))
                   strVar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strAlt.equals("39"))
                   strVar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strVar.equals(" "))
                   strVar = "N/A";
              return strVar;
         // 3.ed.
         public String getWindTempF (String strAlt)
              String strVar;
              String strFar;
              int intRet;
              int intFar;
              strFar = strWea.substring(getPos(strAlt) + 5, getPos(strAlt) + 7);
              if (strAlt.equals("03"))
                   strFar = strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 5);
              if (strAlt.equals("30"))
                   strFar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strAlt.equals("34"))
                   strFar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strAlt.equals("39"))
                   strFar = "-" + strWea.substring(getPos(strAlt) +4, getPos(strAlt) + 6);
              if (strFar.equals(" "))
                   strVar = "N/A";
              intRet = Integer.parseInt(strFar);
              intFar = intRet * (9/5) + 32;
              strVar = Integer.toString(intRet++);
              return strVar;
         // 3.h.
         public String prtWindInfo (String strAlt)
              String strRet;
              strRet = strWea.substring(0,3) + " " + strAlt + "000" + " " +
                   getWindDir(strAlt) + " " + getWindSpeed(strAlt) + " " +
                   getWindTempC(strAlt) + "C " + getWindTempF(strAlt) + "F";
              return strRet;
    }

    Thank you for the reply, soni29. here is the code:
    public int getPos(String strAlt)
              int intAlt;
              int intRet;
              intAlt = Integer.parseInt(strAlt);
              switch (intAlt)
                   case 3:
                        intRet = 4;
                        break;
                   case 6:
                        intRet = 9;
                        break;
                   case 9:
                        intRet = 17;
                        break;
                   case 12:
                        intRet = 25;
                        break;
                   case 18:
                        intRet = 33;
                        break;
                   case 24:
                        intRet = 41;
                        break;
                   case 30:
                        intRet = 49;
                        break;
                   case 34:
                        intRet = 56;
                        break;
                   default:
                        intRet = 63;
              } //     Close switch
              return intRet;
    However, I really don't think there's a problem with any of the coding there. The only times I have problems with the program is when I'm trying to display the data from getWindTempF. If I omit that method, the program works perfectly. Basically, what the program is supposed to do, is hand a string (FAA_FD) to the NWSFD class, which then extracts data from it. Thank you again for the help...any other advice?

  • I need help with a Object Array

    I am having trouble and this maybe really simple seeing that I am fairly new to java but I have text that is being broken down in to preset part with those parts stored in Object arrays.
    Now I also have a object array inside my object array. Within the second object array are the broken down parts of the text and I want to compare this text with another string so for example this is what I am trying
    boolean found = false;
    for (int i = 0; i < FirstObjectArray.length ;i++)
         Object[] SecondObjectArray = (Object[]) FirstObjectArray;
         if(SecondObjectArray[0] == "string")
              found = true;
              break;
         else
              found = false;
    }Help would be very appreciated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    astlanda wrote:
    Sure, you're right.
    [public boolean equals(Object obj)|http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#equals%28java.lang.Object%29]
    sharkura said all the OP needs at the moment. I just wanted to clarify a bit why You don't use == 99.999% of the time with objects, and never with String.
    I have argued elsewhere in these forums that it is inappropriate to tell anyone that you never use == to compare objects. This has not always been accepted. I have, on rare occasions, known experienced developers to blindly compare two objects with equals(), and cite the professor that taught them, 15 years iin the past, that object references are never compared using ==, but always with equals().
    However, the cases where == is appropriate and equals() is not are indeed rare, but not, in my experience, non-existent. In my statement, I probably exaggerated. And String is a case where I can probably accept that you will probably never go wrong with equals(). If the String has been pooled (see String::intern()), you can actually use either. From the javadocs: "*It follows that for any two strings s and t, s.intern() == t.intern() is true if and only if s.equals(t) is true.*"
    ¦ {Þ                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Need help with Calling objects

    I have created an object named "user" and I currently have 1 Frame in my program. The first frame is called "LogonFrame" and the second is called "UserDataFrame".
    In the main method of the application I declare a "User" object as user and then call LogonFrame to retreive the logon_name and password from the user. The logon_name and password will be placed in the User object to be accessed throughout the application.
    When I compile the application I receive the following error message:
    Error: (85) variable user not found in class GL2.LogonFrame
    *I know that 85 is the line number that the error is located
    *GL2 is the name of the package.
    Has anyone ever encountered this error before, and if so how can I fix this error.
    *Listed below is the code used in the User object if it helps at all.
    Jason Franz
    // Copyright (c) 2003 Jason T. Franz
    package GL2;
    * A Class class.
    * <P>
    * @author Jason T. Franz
    public class User extends Object {
    private static int user_id;
    private static String first_name;
    private static String last_name;
    public static void User(){
    user_id = 0;
    first_name = "";
    last_name = "";
    //sets the user ID
    public static void setUserID(int newID){
    user_id = newID;
    //Returns the User ID
    public static int getUserID(){
    return user_id;
    //Sets the User First Name
    public static void setFirstName(String newFirstName){
    first_name = newFirstName;
    //Gets the Users First Name
    public static String getFirstName(){
    return first_name;
    //Sets the Users Last Name
    public static void setLastName(String newLastName){
    last_name = newLastName;
    public static String getLastName(){
    return last_name;
    //Resets all data in the User Class
    public static void reset(){
    user_id = 0;
    first_name = "";
    last_name = "";

    The code below is a small portion of the program.
    If it helps at all I am useing Oracle JDeveloper version 3.2.3 with JDK1.2.2_JDeveloper
    This section is the User object
    // Copyright (c) 2003 Jason T. Franz
    package GL2;
    * A Class class.
    * <P>
    * @author Jason T. Franz
    public class User extends Object {
      private String first_name;
      private String last_name;
      public User(){
        first_name = "Jason";
        last_name = "Franz";
      //Sets the User First Name
      public void setFirstName(String newFirstName){
        first_name = newFirstName;
      //Gets the Users First Name
      public String getFirstName(){
        return first_name;
      //Sets the Users Last Name
      public void setLastName(String newLastName){
        last_name = newLastName;
      public String getLastName(){
        return last_name;
      //Resets all data in the User Class
      public void reset(){
        first_name = "";
        last_name = "";
        logon_name = "";
        user_password = "";
    }Here is the main method.
    // Copyright (c) 2003 Jason T. Franz
    package GL2;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * GL2.DevilsHead
    * <P>
    * @author Jason T. Franz
    public class DevilsHead {
      public User user = new User();
       * Constructor
      public DevilsHead() {
        AddUserFrame frame = new AddUserFrame();
        //Center the window
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = frame.getSize();
        if (frameSize.height > screenSize.height) {
          frameSize.height = screenSize.height;
        if (frameSize.width > screenSize.width) {
          frameSize.width = screenSize.width;
        frame.setLocation((screenSize.width - frameSize.width)/2, (screenSize.height - frameSize.height)/2);
        frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } });
        frame.setVisible(true);
       * main
       * @param args
      public static void main(String[] args) {
        try  {
          UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        catch (Exception e) {
          e.printStackTrace();
        new DevilsHead();
    }and here is the Frame which calls the user object to display the Information.
    // Copyright (c) 2003 Jason T. Franz
    package GL2;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    * A Swing-based top level window class.
    * <P>
    * @author Jason T. Franz
    public class AddUserFrame extends JFrame {
      BorderLayout borderLayout1 = new BorderLayout();
      JPanel jPanel1 = new JPanel();
      Button button1 = new Button();
       * Constructs a new instance.
      public AddUserFrame() {
        super();
        try  {
          jbInit();
        catch (Exception e) {
          e.printStackTrace();
       * Initializes the state of this instance.
      private void jbInit() throws Exception {
        this.getContentPane().setLayout(borderLayout1);
        this.setSize(new Dimension(400, 300));
        button1.setLabel("button1");
        button1.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
            button1_actionPerformed(e);
        this.setTitle("Add a User");
        this.getContentPane().add(jPanel1, BorderLayout.CENTER);
        jPanel1.add(button1, null);
      void button1_actionPerformed(ActionEvent e) {
        System.out.println(user.getFirstName());
        System.out.println(user.getLastName());
    }The error I receive is
    Error: (51) variable user not found in class GL2.AddUserFrame

Maybe you are looking for

  • IPad 3rd gen no longer charges unless shut off and not recognized by iTunes

    iPad 3rd gen no longer charges unless shut off and not recognized by iTunes.  Done 2 resets, used original charger and cable and bought brand new charger and cable from Apple store.  Nothing works.  This started yapping after the iOS 7.1.1 update.

  • Migration issue iMac to MacBook Pro

    Migrating data from iMac OS X Lion 10.7.5 to  new MacBook Pro.  Using ethernet and wifi connection to migrate.  MacBook has identified iMac for migration including code; but the iMac is not identifying the MacBook.  Any suggestions?

  • Thinkpad T61 VGA Out [SOLVED]

    I'm having trouble getting VGA out working with my T61 (never had it working in linux).  I dualboot and it's fine in windows, so this isn't a hardware issue. Fn+F7 apparently does nothing.  nvidia-settings (I have a quadro nvs 140m) will detect an ou

  • Sum of all order amts

    I want to be able to find the sum of all order amts from an itab that I read. The total needs to be 12 digits left filled with zero and decimal dropped data: totalorderamt(12) type n value 0. in the loop should it be totalorderamt = totalorderamt + t

  • How do I set Acrobat as default over Reader?

    I use Acrobat Professional but recently installed Reader to check my PDF forms. Can someone tell me how to set Acrobat as the default program in favor of Reader? Thanks