Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Lv 44,285 points

xXBrudu BXx

Favorite Answers8%
Answers1,208

I am known as xXBrudu BXx. I'm 16, and I think too much. That is really everything that the planet needs to know for now. If you need to talk to me about anything, the email button is there. Feel free.

  • Java Inheritence question?

    I am working on an Inheritance program for class, and I have run in to a bit of a problem. It would appear that, even though the class works properly, it does not want to print more than just the super-class. It appears that the child class is working properly, as the compiler yelled at me for my earlier typos, but it does not print what it should. I am using JCreator, and I have both Java files in the same directory on my hard drive. I posted to pastebin.

    Super: http://pastebin.com/FkySiC1Q

    Child: http://pastebin.com/BdjvH0GY

    3 AnswersProgramming & Design1 decade ago
  • Getting a Null Pointer in my Sorting method?

    http://pastebin.com/8E6uuPcA <--- That is my code as it stands

    I am trying to write a class that takes an array, sorts it, breaks it in half like a merge sort would, and put the second half in descending order, so that it can print a small number, then a big number, and go all the way down like that. I am pretty sure that I set up the algorithm correctly. But, for some reason, I am getting a Null Pointer exception on line 62. Can anybody see what I screwed up?

    Thanks in Advance.

    2 AnswersProgramming & Design1 decade ago
  • Trying to print an ArrayList with a loop?

    I have posted my main method (There are others, but they are not being implemented yet) since I am trying to print my ArrayList, but I am getting an error telling me that the symbol myGarage doesn't exist. What am I doing wrong?

    public static void main(String[] args){

    autoGarage car1 = new autoGarage(50, 12);

    autoGarage car2 = new autoGarage(50000, 14);

    autoGarage car3 = new autoGarage(59021, 18);

    autoGarage car4 = new autoGarage(193844, 16);

    ArrayList myGarage = new ArrayList<autoGarage>();

    myGarage.add(car1);

    myGarage.add(car2);

    myGarage.add(car3);

    myGarage.add(car4);

    for (int i = 0; i < myGarage.size(); i++)

    System.out.println(myGarage(i));

    }

    2 AnswersProgramming & Design1 decade ago
  • How do I properly call a method from another class?

    I am writing a class to test the methods of another class that I wrote. The class that is to be tested is an array of objects class which has an array of Baseball Players with several attributes. I am currently trying to write a Driver file that will test the methods in my other class.

    For example: I have a method

    public boolean findPitcher(baseballPlayer Team[])

    I am trying to call that from my driver by saying

    if (Team.findPitcher() == true)

    System.out.println("This team has a pitcher");

    The first piece of code is its own method of my baseballPlayer class, and the second is in the Driver class in the main method.

    I am getting an error that the method cannot be located. And, yes, the java source files are in the same directory.

    7 AnswersProgramming & Design1 decade ago
  • How do I properly pass this array of objects?

    I am working on creating multiple methods with this Team[] array as the parameter. As of now, just to test the array, I am attempting to print each of its elements. The code is as follows:

    (View on pastebin if you prefer at: http://pastebin.com/wibCZBmX )

    /**

    * @(#)baseballPlayer.java

    *

    * baseballPlayer application

    *

    * @author

    * @version 1.00 2010/11/14

    */

    public class baseballPlayer {

    private String myFirst;

    private String myLast;

    private double battingAv;

    private String pos;

    private String tName;

    //Player constructor; a player will have a First and Last name, a batting average displayed as a decimal, a position and a team name"

    public baseballPlayer(String myFirst, String myLast, double battingAv, String pos, String tName)

    {

    this.myFirst = myFirst;

    this.myLast = myLast;

    this.battingAv = battingAv;

    this.pos = pos;

    this.tName = tName;

    baseballPlayer Team[] = new baseballPlayer[8];

    Team[0] = new baseballPlayer("Michael", "Beron", 0.500, "First Base", "Yankees");

    Team[1] = new baseballPlayer("Michael", "Jordan", 0.019, "Second Base", "Yankees");

    Team[2] = new baseballPlayer("Derek", "Jeter", 0.462, "Short Stop", "Yankees");

    Team[3] = new baseballPlayer("John", "Kerry", 0.093, "Third Base", "Yankees");

    Team[4] = new baseballPlayer("Jorge", "Posada", 0.482, "Left Field", "Yankees");

    Team[5] = new baseballPlayer("Carlton", "Banks", 0.142, "Center Field", "Yankees");

    Team[6] = new baseballPlayer("Uncle", "Phil", 0.354, "Right Field", "Yankees");

    Team[7] = new baseballPlayer("Jason", "Giambi", 0.467, "Catcher", "Yankees");

    Team[8] = new baseballPlayer("Charles", "Chen", 0.569, "Pitcher", "Yankees");

    }

    public static int createArrays(baseballPlayer Team[])

    {

    for (int x = 0; x < Team.length; x++)

    System.out.println(Team[x]);

    return 1;

    }

    public static void main(String[] args) {

    }

    }

    3 AnswersProgramming & Design1 decade ago
  • What is wrong with my code?

    I am working on a program for school. Ultimately, the program will create an array of objects, with the concept of baseball players being stored as objects in an array that will be the Team. However, for now, I am just working on getting the object created properly. So far, my code is as follows:

    /**

    * @(#)baseballTeam.java

    *

    * baseballTeam application

    *

    * @author

    * @version 1.00 2010/11/14

    */

    public class baseballPlayer {

    private String myFirst;

    private String myLast;

    private double battingAv;

    private String pos;

    private String tName;

    //Player constructor; a player will have a First and Last name, a batting average displayed as a decimal, a position and a team name"

    public baseballPlayer(String myFirst, String myLast, double battingAv, String pos, String tName)

    {

    String nameFirst = "Michael";

    String nameLast = "Smith";

    double batAver = 0.500;

    String position = "First Base";

    String nameTeam = "Yankees";

    myFirst = nameFirst;

    myLast = nameLast;

    battingAv = batAver;

    pos = position;

    tName = nameTeam;

    baseballPlayer mSmith = new baseballPlayer(nameFirst, nameLast, batAver, position, nameTeam);

    }

    public static void main(String[] args) {

    System.out.println(mSmith);

    }

    }

    My question is, what am I doing wrong? I am trying to print the object for now, just so I can see that I did it properly, however I am getting the error, C:\Documents and Settings\Bergen Profile\My Documents\JCreator LE\MyProjects\baseballPlayer\src\baseballPlayer.java:40: cannot find symbol

    symbol : variable mSmith

    location: class baseballPlayer

    System.out.println(mSmith);

    Any help would be greatly appreciated.

    6 AnswersProgramming & Design1 decade ago
  • Help calling methods in Java?

    My code is posted on pastebin as follows:

    http://pastebin.com/aHcuXvyJ

    I just need to call my returns, but I am unsure how to do that properly. I believe I had all the data move to the other methods correctly. All that is left is to output the data. Any suggestions?

    3 AnswersProgramming & Design1 decade ago
  • Help with my loop in my class (Java)?

    I have posted my code on pastebin so that it would be formatted. The link is http://pastebin.com/KnwiAtex

    First off, what the program needs to do. The program needs to take a certain amount of grades, and decide whether or not a student is eligible for sports. In order to be eligible, a student must have no F's, have more than 4 classes, and have a GPA that is greater than 2.0

    My program, for some reason, keeps turning my GPA into a negative value, and the loop seems to get bypassed, jump straight to the out statements, and then go back in to the loop. Also, when I compile, I get the error that the variable counter in my loop cannot be located. I can't seem to figure out why I can't use the variable outside of the loop. If anybody could give me some pointers, I would greatly appreciate it.

    3 AnswersProgramming & Design1 decade ago
  • Variable might not have been initialized in Java; Where did I mess up?

    The code is as follows:

    /**

    * @(#)IRSTaxCalculator.java

    *

    * IRSTaxCalculator application

    * This program will calculate taxable pay based on marital status and income.

    * @author

    * @version 1.00 2010/10/11

    */

    import java.util.Scanner;

    public class IRSTaxCalculator {

    public static void main(String[] args) {

    // These are the values that will be needed to be pre-defined

    // The following takes the input for the value of marital status

    System.out.println("Please press 1 if you are Single, 2 if you are Married, or 0 if you would like to quit.");

    Scanner alpha = new Scanner(System.in);

    int status = alpha.nextInt();

    //The following is the escape sequence

    if (status == 0)

    System.out.println("Thank you, and please use this program again.");

    // This calculates taxes for Single people

    else if (status == 1)

    {

    double taxes;

    System.out.println("Please input your salary. No special characters, please.");

    Scanner beta = new Scanner(System.in);

    double salary = beta.nextDouble();

    if (salary >= 0 && salary <= 27050)

    taxes = salary * 0.15;

    if (salary > 27050 && salary <= 65500)

    taxes = (salary-27050) * 0.275 + 4057.50;

    if (salary > 65500 && salary <= 136750)

    taxes = (salary-65500) * 0.355 + 36361;

    if (salary > 136750)

    taxes = (salary-136750) * 0.391 + 88306;

    if (salary < 0)

    System.out.println("I think you put in a negative value. Either you are making a mistake, or you need to stop gambling.");

    //This is the output statement for these lines

    System.out.println("You filed your taxes as single");

    System.out.println("Your taxable salary is " + salary);

    System.out.println("Your taxes are " + taxes);

    }

    //This calculates the taxes for married people

    else if (status == 2)

    {

    double taxes;

    System.out.println("Please input your salary. No special characters, please.");

    Scanner beta = new Scanner(System.in);

    double salary = beta.nextDouble();

    if (salary >= 0 && salary <= 45200)

    taxes = (salary) * 0.15;

    if (salary > 45200 && salary <= 109250)

    taxes = (salary - 45200) * 0.275 + 6780;

    if (salary > 109250 && salary <= 166500)

    taxes = (salary - 109250) * 0.305;

    if (salary > 166500 && salary <= 297350)

    taxes = (salary - 166500) * 0.355 + 41855;

    if (salary > 297350)

    taxes = (salary - 297350) * 0.391 + 88306;

    if (salary < 0);

    System.out.println("I think you put in a negative value. EIther you are making a mistake, or you need to see what your spouse is doing with your money.");

    System.out.println("You filed your taxes as married");

    System.out.println("Your taxable salary is " + salary);

    System.out.println("Your taxes are " + taxes);

    }

    }

    }

    I can't for the life of me figure out what I did wrong. I'm relatively new at this, so I am sure it is some stupid little mistake. The program takes marital status, applies it to a tax group, takes the salary, plugs it in given the marital status, and decides how much your taxes for the year are. I can't get the double taxes to work. Any ideas?

    3 AnswersProgramming & Design1 decade ago
  • How Do I Complete This Java Program?

    I already have

    import java.util.Arrays;

    public class firstprogram11beromi {

    public static void main(String[] args) {

    int[] numbers = {19, 13, 17, 12, 16, 15, 18};

    Arrays.sort(numbers);

    int num = numbers[0];

    for (int i = 1; i < numbers.length; i++){

    num ++;

    if(num != numbers[i])

    System.out.println(numbers);

    break;

    }

    }

    }

    as my code (as per the suggestion of a user earlier, as well as a minor modification) in order to take those numbers, sort them from least to greatest, and then fill in the missing number (14)

    I am a beginner in Java, and I am trying to finish this up so I can go to sleep, because I have been at it for hours. Any and all help is greatly welcomed.

    5 AnswersProgramming & Design1 decade ago
  • How can I solve this Java problem?

    I am a beginner in Java, but for AP Computer Science, the teacher would like us to solve the following problem.

    You are given a sequence of n distinct integers in the range k to k + n, for some k, in arbitrary order. In other words, one of the n + 1 integers in the range is missing from the input. Your goal is to find the missing number.

    Your input will look something like this:

    19 13 17 12 16 15 18

    Your program should output 14 which is the missing number in the sequence.

    This program should work for any size sequence. The example above is an 8-number sequence. Before you even begin to write Java, solve this problem by hand. If you put the above numbers in order, you get:

    12 13 15 16 17 18 19

    Obviously, the missing number is 14.

    You will write a program in Java that takes an out-of-order sequence as input, determines the missing number, and outputs the missing number.

    Would anybody be willing to point me in the right direction on how to do this? I know that I need to create an array, but I don't know how to get the array to sort the numbers or figure out the missing number. I have been working on this for hours to no avail, so any help would be appreciated tremendously.

    6 AnswersProgramming & Design1 decade ago