Trouble understanding treemap question

Okay,
here is the question:
Create 10,000 unique random key values in the range 10,000 to 100,000. Hold them in array key. Use Random class's nextInt(n) method to add a random offset to the last randomly value generated. Start with value 1.
rn = rn + aRandom.nextInt(7) + 1;
Store Data Objects in the TreeMap and HashMap. Data Objects have the following 4 fields:

(my post was cut off)
Create 10,000 unique random key values in the range 10,000 to 100,000. Hold them in array key. Use Random class's nextInt(n) method to add a random offset to the last randomly value generated. Start with value 1.
rn = rn aRandom.nextInt(7) 1;
Store Data Objects in the TreeMap and HashMap. Data Objects have the following 4 fields:
int id; // key;
string name; // select from 5 names with key[i] % 5
int age; // 20 + ley % 30
string gender; // select from "male" or "female" with key[i] % 2the random key values, key, are integers. How do you select from 5 names, that are strings, with key[i] modulus 5?

Similar Messages

  • Trouble understanding programing question.

    Hey guys,
    Got a program im supposed to write its bonus and I have already done the original program. Problem is Ive read the instructions and they are kinda confusing to me. If I could just understand what they are saying then it will make this much easier. So if anyone can shed some light on what im missing id be thankful.
    Heres the program instructions.
    Question 2: Design and implement a recursive method that implements the factorial method n!. The factorial method n! is defined by
    n!= n*(n-1)*(n-2)*�*1
    Place the method in a class that has a main that tests the method.
    Does this just mean I need to make a method that finds the factors of a variable (e.g the factors of 10)? Which would be 2 and 5 right? Or would this mean make a recursive method that finds the factors of 10*n. like 1 * 10 = 10, 2 * 10 = 20, 3 * 10 = 30 etc etc.... And Im guessing that that algorightm cant be used in a program. In other words the *....*1 and n! are not correct syntax and that algorithm is just a abstract example to give me some direciton im not actually supposed to try and replicate it exactly as it is right? Usually I dont have problems with instructions but this one just confused the hell out of me. Any help would be great thank you. I would have asked the teacher but I thought I understood it and now I dont see the profeesor until the day its due and also she has a foreign accent so its hard for me to understand.
    Message was edited by:
    venture

    No. You have to do the factorial.
    3! = 3*2*1 = 6
    4! = 4*3*2*1 = 24
    etc
    You should see a pattern ie 4! = 4 * 3!. In the
    question you were given the equation for calculating
    it. If you can't do it Google is your friend becuase
    it has been done millions of times before.
    Slow! Well it is hard to type with these fins.
    Message was edited by:
    flounderThat makes sense thank you.

  • HT4623 I upgraded my iphone4S yesterday and Siri response with "having trouble understanding".  Is there an upgrade for Siri?

    I upgraded my iPhone4S to iOs6 and now Siri does not understand me.  Siri responses "having trouble understanding you, try again".  Is there an updgrade for Siri?  I have been searching all afternoon for a glimmer of a solution.  Any suggestions?

    Sure...
    See this Apple article for a Hard reset of a Factory reset.
    http://support.apple.com/kb/HT3728

  • Have Trouble understanding the runnable interface

    Hi
    I am new to java programming. I have trouble understanding threading concepts.When I run the below code,Thread3 runs first. I need a small clarification here- I created two thread objects
    Thread thread1=new Thread(new RunnableThread(),"thread1");
    Thread thread2=new Thread(new RunnableThread(),"thread2");
    As soon as I create these objects -Will the constructor with the string argument in the "RunnableThread" class gets invoked. If so why doesn't System.out.println(runner.getName()); get invoked for the above objects. what is the sequence of execution for the below program.
    /*************CODE****************************/
    class RunnableThread implements Runnable
         Thread runner;
         public RunnableThread()
         public RunnableThread(String threadName)
              runner=new Thread(this,threadName);          //Create a new Thread.
              System.out.println(runner.getName());
              runner.start();          //Start Thread
         public void run()
              //Display info about this particular Thread
              System.out.println(Thread.currentThread());
    public class RunnableExample
         public static void main(String argv[])
              Thread thread1=new Thread(new RunnableThread(),"thread1");
              Thread thread2=new Thread(new RunnableThread(),"thread2");
              RunnableThread thread3=new RunnableThread("thread3");
              //start the threads
              thread1.start();
              thread2.start();
              try
                   //delay for one second
                   Thread.currentThread().sleep(1000);
              catch (InterruptedException e)
              //Display info about the main thread
              System.out.println(Thread.currentThread());
    }

    srinivasaditya wrote:
    Hi
    I am new to java programming. I have trouble understanding threading concepts.I'd consider it to be an advanced area.
    When I run the below code,Thread3 runs first. I need a small clarification here- I created two thread objects
    Thread thread1=new Thread(new RunnableThread(),"thread1");
    Thread thread2=new Thread(new RunnableThread(),"thread2");No, this is wrong. You don't need your RunnableThread. Runnable and Thread are enough. Your wrapper offers nothing of value.
    >
    As soon as I create these objects -Will the constructor with the string argument in the "RunnableThread" class gets invoked. If so why doesn't System.out.println(runner.getName()); get invoked for the above objects. what is the sequence of execution for the below program.did you run it and see? Whatever happens, that's the truth.
    %

  • Having trouble understanding Abstract class. Help!!!!!!

    Having trouble understanding Abstract class. when is Abstract class used and for what.

    Having trouble understanding Abstract class. when is
    Abstract class used and for what.An abstract class is used to force the developer to provide a subclass, to implement the abstract methods, while still keeping the methods that were provided.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Trouble Understanding Logic of Primes Program

    I am reading a book called Beginning Java 7, by Ivor Horton. In his book he has a primes calculation program. The code is below. I am having trouble understanding the logic of the program. I've stared at it for the past several hours with no luck. What I can't understand is how both i and j are both initialized to 2 but the if statement:
    if(i%j == 0) {
              continue OuterLoop;                                         
            }then passes a 2 to the println() function. I am totally lost on this problem. The program below outputs all of the prime numbers from 2 to 50 without any errors. Please help!
    Thank you.
    public class Primes2 {
      public static void main(String[] args) {
        int nValues = 50;                                                  // The maximum value to be checked
        // Check all values from 2 to nValues
        OuterLoop:
        for(int i = 2 ; i <= nValues ; ++i) {
          // Try dividing by all integers from 2 to i-1
          for(int j = 2 ;  j < i ; ++j) {
            if(i%j == 0) {                                                 // This is true if j divides exactly
              continue OuterLoop;                                          // so exit the loop
          // We only get here if we have a prime
          System.out.println(i);                                           // so output the value
    }Edited by: EJP on 27/03/2013 19:54: fixed all the bizarre formatting, spelling, and removed the even more bizarre comment marketers around the text. Please use standard English and its existing conventions here.

    Hi. I did notice that. What I don't understand is how 2 is outputted as a prime number when the Net Beans debugger shows that i's value is 3 in the if statement. Where does the value 2 come from? Thanks.
    Edited by: 996440 on Mar 27, 2013 3:07 PM

  • Trouble understanding KMP algorithm

    If anyone is familiar with the KMP skip search algorithm and cares to shed some light on the subject. I am having trouble understanding how the table is derived, as many examples i come across seem to be using different variations. The table used to control the search.
    Thanks a million in advance, Mel

    JosAH wrote:
    The failure function can be a bit of a burden to fully understand but realize that it gives you the next index of the string to search for if the current match for a prefix of the pattern failed. thats kind of what i wanted to hear lol, thanks both of you
    and i took ur advice, i did the whole example on pen and paper. i would be lieing if i said i fully understand it, but i do have a better understanding now.
    Mel

  • Trouble understanding static objects

    Hello,
    I have trouble understanding static objects.
    1)
    class TestA
    public static HashMap h = new HashMap();
    So if I add to TestA.h from within a Servlet, this is not a good idea, right?
    But if I just read from it, that is ok, right?
    2)
    class TestB
    public static SimpleDateFormat df = new SimpleDateFormat();
    What about TestB.df from within a Servlet? Is this ok?
    example: TestB.df.format(new Date(1980, 1, 20));

    There is exactly one instance of a static member for every instance of a class. It is okay to use static members in a servlet if they are final, or will not change. If they may change, it is a bad idea. Every call to a servlet launches a new thread. When there are multiple calls, there are multiple threads. If each of these threads are trying to make changes to the static memeber, or use the static memeber while changes are being made, the servelt could give incorrect results.
    I hope that helped..
    Thanks
    Cardwell

  • Major trouble understanding structure

    Hello,
    This is my first time creating a Photoshop Plugin, and I am having a lot of trouble understanding how to do it. I am using Microsoft MFC to create it. Does anybody know of good references or sample code to look at? I simply don't get how to create this!!!
    I am trying to do a filter plugin that will let the user select a particular color, and turn all other colour in the image to black and white.
    Thanks.

    There is one MFC sample in the SDK. It doesn't sound like you are having trouble with MFC per say but more about getting pixels in and out of Photohsop. Where exactly are you having troubles? Maybe the Dissolve sample will help you out but it uses OS (Win32) API's and not MFC.

  • Trouble with TreeMap

    Hallo everyone,
    I have as a Input CSV-like text file with a names of Decathlon athletes who have 10 diffrent results of each compitition written after each name. I made two classes, one (for the athletes) with String name and one for the Results with int points and Method that converts the times into Decathlon points. I could get all the names and the their points outputed. So it works fine. Now the trouble is that I have to put them in ascending order of their places. So I have to save them some how to compare with each other. I tried to use TreeMap for that. But can not understand how it works, cuz both key and value have to be taken from the file. Not like this example shows:
    Map textFieldMap = new HashMap();
    textFieldMap.put("1", new JTextField());
    textFieldMap.put("2", new JTextField());
    JTextField textField = (JTextField)textFieldMap.get("1");
    textField.setText("some value"); // text field associated with "1"
    but so that the loop puts the points as the key and name as value into TreeMap so at the end I could output it in ascending order. I really was trying to fix the problem but couldnt fine the solution. Can someone explain me how it works. I paste my main method code whitch outputs:
    4197 Siim Susi
    3199 Beata Kana
    3493 Jaana Lind
    3101 Anti Loop
    so hier is the code:
    I import io*, util*, lang*
    public class Decathlon {
    public static void main(String args[]) throws Exception {
    //read data from file
    File f = new File("C:\\Dokumente und Einstellungen\\RT\\IdeaProjects\\HansaDecat\\src\\10v_tulemused.txt");
    BufferedReader source =
    new BufferedReader(new FileReader(f));
    String line; //input of one line
    Results oneResult = new Results();
    Sportsmen oneSportsman = new Sportsmen();
    Time2Double timeobject = new Time2Double();
    TreeMap map = new TreeMap();
    int z=0;
    while ((line = source.readLine()) != null) {
    for (int i = 0; i <= 10; i++) {
    String[] lineUnits = line.split(";");
    if (i == 10) {  // 10th competition
    String aeg = lineUnits[10];
    StringTokenizer st = new StringTokenizer(aeg, ".");
    for (int a = 0; a < 3; a++) { //devide last result into 3 parts to convert to double
    timeobject.ConvertTime(a, Double.valueOf(st.nextToken()));
    lineUnits[10] = String.valueOf(timeobject.Time); // String.valueof(return of time)
    if(i<1){
    oneSportsman.setName(String.valueOf(lineUnits));
    }else
    oneResult.countScore(i, Double.valueOf(lineUnits[i]));
    //System.out.println(lineUnits[i] + " index" + i);
    // map.put (new Integer(z), new Data(oneResult.getName()));
    // System.out.println(z++);
    // map.put(new Results(), new Sportsmen());
    Sportsmen Sportsman = (Sportsmen)map.get(oneResult.points);
    // Sportsman.setName(oneSportsman.getName()); // text field associated with "1"
    // System.out.println("All sportsmen in Hashtable:\n" + map);
    System.out.println(oneResult.points+" "+oneSportsman.getName());
    /** ( Results elem : map.keySet() )
    System.out.println( elem ); */
    source.close();
    Thank you for Help
    Tanja

    you can use TreeSet instead of TreeMap in that use Comparable interface and override equal and compare methods

  • Trouble Understanding variables

    I am committed to learning A3, but HOLY CRAP!! I have never
    been a programmer, just a lowly designer. Apparently a pretty dumb
    designer! :)
    I can breeze through this in AS2 with no problem, but AS3 is
    killin' me! I am trying to create a music player that will embed in
    a web page, it will be XML driven and the XML will be populated via
    a database and generated by PHP. I am using a listbox component to
    display the playlist (from the XMLfile). I have figured out how to
    start playing the first mp3 on the list.
    Now when the user click a different button, I can get that
    song to play also, but I ended up created a second sound object, so
    the two play at the same time. Not good. I have tried and tried to
    access the object that is playing the first sound so I can stop it
    and load a new sound into it - I am about to pull my hair out!
    I seem to missing a basic understanding of how to access this
    object and change the variable value so I can play a new song. Any
    help would be GREATLY appreciated!!

    Vern,
    > If I understand correctly: any variable I am going to
    use outside
    > of the function that assigns its value needs to be
    declared OUTSIDE
    > of that function first?
    Yes.
    > Once declared it can be used anywhere, but if it isn't
    declared
    > outside, then the value is stuck inside that function.
    Is that correct?
    Close. In fact, if you're coding in the main timeline,
    you're so close,
    you could arguably define it in those terms and be fine.
    Variables (and
    functions) are available to the scope in which they're
    declared. If you
    declare a variable in the main timeline, then that variable
    is available in
    that frame and any subsequent frame of that timeline.
    Depending on the
    circumstances of your FLA, the main timeline may indeed feel
    like
    "everywhere," to the point where the variable could be said
    to be used
    "anywhere" -- but it's really not much different from the
    restriction a
    variable feels when declared inside a function; it's just
    that the whole
    movie takes place inside that "function"/FLA/SWF.
    > If I got that right, then for my scrubber, I need to set
    up some
    > variables that hold SoundChannel.position, Sound.length,
    > MovieClip.position
    > THEN create a function which assigns values and
    calculate the
    > MovieClip.position
    Yes. That way, any number of functions can use those
    variables. But
    keep in mind, all you really need are variables that point to
    your instances
    of Sound, SoundChannel, and MovieClip. Then use those
    variables to
    reference the necessary properties of those classes. (In
    other words, no
    need to make a mySound variable *and* a mySoundLength
    variable: the mySound
    variable suffices, because it leads to the Sound.length
    property as simply
    as mySound.length.)
    > I never liked how clunky onEnterFrame could is. I assume
    the Timer
    > class is a bit more streamlined?
    It's just another tool in the toolbox. :) Timer is the
    recommended new
    version of setInterval() and setTimeout() combined.
    > I am so used to _root.movieClip.variable=foo; (I mean
    the easy
    > access to any variable from anywhere) but change is
    good, I like
    > change. Change is good.
    I like change in my pocket! ;) The thing about an expression
    like
    _root.movieClip.variable is that you could often just
    reference the variable
    anyway, without the need for the "_root" reference. AS3 has
    root (no
    underscore), which behaves in many ways like _root, but dig
    into that a bit
    ... you'll find some important differences.
    > So it sounds as if, to include the loadbar within all of
    this, then I need
    > to move the playHead along the width of the loadbar, not
    a set length
    > in pixels.
    You could do a set length, but it's much more flexible if
    you use the
    width of some other object, like a track or some other movie
    clip. If you
    go with the width of some object, you can *change* the width
    of that object
    and the code still works.
    > The drag part should be easy enough, but adjusting the
    actual audio
    > from that may give some fits!
    To derive volume, you'll take the position of the draggable
    knob along
    its track and divide that by the width of the track. Assume
    you have a
    ridiculously long volume track, 500px. The volume knob has
    been dragged
    halfway across, to 250px. 250 / 500 is 0.5, which is the AS3
    way of
    specifying 50% volume. Now imagine the track is 50px wide.
    The knob has
    been dragged all the way across (to 50px). 50 / 50 is 1,
    which is 100%
    volume. And so on.
    > But here is my real question about that, will it be OK
    to try and add
    > that functionality in once the actual playHead is
    working, or is
    > that a mistake to not include it from the beginning?
    Ehh, for something like this -- especially if you're
    teaching yourself
    and involved in a learning experience -- I'd say it doesn't
    matter one way
    or the other. Take small steps and master each step. Sooner
    or later, what
    you're doing will "click" for you, and after that, you'll
    find that you can
    add or remove features as you please.
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Trouble understanding RH customization when linking FM files

    Is there a video that will help with this, particularly creating and customizing a single CSS for use with my work? I also would like to have an idea of the best workflow.
    Here is what I am doing and some issues:
    Open RH.
    Click File > New > Project.
    What I really want is a bunch of HTML files with known filenames. I know FM 12 can do this without RH, but I want to work this out now so I can take this in a better direction. Anyway, I click Application Help in Project Type.
    Click the Import tab in the New Project dialog box.
    Select FrameMaker Documents as the Import Type, and click OK.
    Select my FrameMaker .book file, and click Open.
    Enter a title for the project, file name for the project (left default), and location for the project.
    Click Finish.
    At this point, my multi-FM-file .book project hangs and never finishes. If I am using a single-FM-file .book project, though, the following happens:
    The Import dialog box opens.
    In the FrameMaker Document area, click Edit. Some scanning happens, and the Conversion Settings dialog box opens.
    Edit paragraph settings.
    Find those paragraphs I don't want output for and select the Exclude from output check box, such as Footer.
    Set each of my four Bulletn styles to Multilevel list. Bullet1, Bullet2, Bullet3, and Bullet4 styles represent decreasing levels of subbulleted lists.
    Set my eight Stepsn styles to Multilevel list. Steps1, Steps2, Steps3, and Steps4 styles represent decreasing levels of subnumbered lists (1, a, I, i). Each of these styles has a corresponding First style that sets the numbering to 1, such as Steps1First.
    Set up cross reference settings to remove page numbers.
    Set the default format for Image to .png.
    Leave Character, and Other settings alone.
    Click OK and Next.
    Leave the Table of Contents, Index, and Glossary Settings turned off.
    Click Finish. Some scanning happens and a result is created.
    Some issues.
    While Mutilevel Numbering creates 4 appropriate levels of bullets based on my styles, it only creates 3 of 4 levels of numbered lists. Levels 3 and 4 are presented identically by RH. How did this happen and how do I fix it.
    Indented body tags are not correct. I can fix this in the CSS. But, then, how do I create and make sure my project uses a new CSS?
    How do I create a delivery package for this? I see what I have in project manager, and want to create a folder that contains my output, that is, HTML, PNG, and CSS files that support my project so I can move these to the target CD or delivery mechanism?
    I have HTML and CSS buried within individual folders with the respective FM source. How do I get these HTML files and images out, and mate them to one and only one CSS for delivery?
    Thoughts?
    Sean

    Thanks. I will choose Blank Project  instead if Application from now on, though I understand that is erased by choosing FM files. I really just want compliant HTML 5 output with a single CSS file that I can deploy with linked files, which will be PNGs.
    So, can you  help with my customization questions?
    Also, another issue I have run into is spacing in the HTML around run-in headings. This is caused by RH adding an extra blank paragraph with a non-breaking space, as show in the following code. I don't need this empty paragraph added, and it was not in the FM source. Thoughts?
    <p class="FM_GlossaryTerm">Term Name Here as a runin in FrameMaker.</p>
    <p class="FM_GlossaryTerm">&#160;</p>  //<-- This line added in RH conversion, and I don't want it.
    <p class="FM_GlossaryDefinition">Term definition paragraph here.</p>
    Cheers,
    Sean

  • Trouble understanding JTable renderers

    I dont properly understand how to JTable.
    In the application I'm writing, I have on main JFrame, with a menu.
    Onto this I load a jTabbed pane and then onto this a JTable , with
    some data loaded from a file , some coulmns are text , others integers
    floats and theres one date column
    I've successfully set up a TableModel extending AbstractTableModel
    as a separate class java file. I can set column widths ok too.
    But I cant get the renderer working , the numeric coumns are left aligned.
    Question 1 :How do I get a column of numeric data in a JTable to be right aligned? Some examples I have found seem to refer to specific cells eg
    // in the custom renderer...
    if(value instanceof Double)
    setHorizontalAlignment(SwingConstants.RIGHT);
    setText(value);
    I've also read this sites JTable tutorial but still dont understand the
    renderer bit.
    Question 2 : where do I put the renderer code, in with the table model
    class file , or in my main application (where I define the column widths)?
    [The JDK is 1.4, the OS is win 98.]
    Thanks in advance for any help
    Mike2z

    HONK !
    Thanks for the reply. The code
    public Class getColumnClass(int c)
    switch (c)
    case 0: return Integer.class;
    case 1: return String.class;
    case 2: return String.class;
    case 3: return String.class;
    case 4: return String.class;
    case 5: return String.class;
    case 6: return Integer.class;
    case 7: return Float.class;
         case 8: return Float.class;
    case 9: return Float.class;
    case 10: return Floatclass;
    default : return getValueAt(0, c).getClass();
    // return getValueAt(0, c).getClass();
    // return Object.class;
    seems to be the key. When I use that (instead of either of the commented
    out lines I was trying before) it works in that numbers are right
    aligned.
    However when I attemp to right scroll on the scroll pane I get a garbled display and the error :
    java.lang.IllegalArgumentException: Cannot format given Object as a Number
         at java.text.NumberFormat.format(NumberFormat.java:219)
         at java.text.Format.format(Format.java:133)
         at javax.swing.JTable$DoubleRenderer.setValue(JTable.java:3348)
         at javax.swing.table.DefaultTableCellRenderer.getTableCellRendererComponent(DefaultTableCellRenderer.java:160)
         at javax.swing.JTable.prepareRenderer(JTable.java:3682)
         at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1149)
         at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
         at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
         at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
         at javax.swing.JComponent.paintComponent(JComponent.java:537)
         at javax.swing.JComponent.paint(JComponent.java:804)
         at javax.swing.JComponent.paintChildren(JComponent.java:643)
         at javax.swing.JComponent.paint(JComponent.java:813)
         at javax.swing.JViewport.paint(JViewport.java:707)
         at javax.swing.JComponent.paintChildren(JComponent.java:643)
         at javax.swing.JComponent.paint(JComponent.java:813)
         at javax.swing.JComponent._paintImmediately(JComponent.java:4642)
         at javax.swing.JComponent.paintImmediately(JComponent.java:4464)
         at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:404)
         at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:443)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:190)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:144)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:130)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:98)
    If I just use
    public Class getColumnClass(int c)
    return getValueAt(0, c).getClass();          // this
    // return Object.class;          // or this
    I can right scroll without that error appearing, but am back to the original problem of left aligned numeric data.
    Don't suppose you encountered the same problem?
    Mike2z

  • Understanding the Question

    I'm working on an assignment and I don't quite understand the instructors question on what she's looking for. I'll post it in several posts due to the forums post restrictions.
    Question:
    Modify SpeciesSecondTry by adding the fourth feature, averageLifespan (as double), to a species and revise SpeciesSecondTryDemo accordingly.
    Problem:
    I would imagine to get an average life span you would add the total years of all the species and divide by the number of species. I do not see how I can make a mathmatical equation from this code.
    Additionally, SpeciesSecondTryDemo is returning an error regarding printing. Have I not defined .average the same way as .name, etc?
    E:\WU\CSC117 Java II\Exercise 2\SpeciesSecondTryDemo.java:31: cannot find symbol
    symbol  : variable average
    location: class SpeciesSecondTry
             System.out.println("The average life span of the " +speciesOfTheMonth.name +" is " +speciesOfTheMonth.average);
                                                                                                                  ^
    1 errorSpeciesSecondTryDemo.java
    public class SpeciesSecondTryDemo
        public static void main(String[] args)
            SpeciesSecondTry speciesOfTheMonth = new SpeciesSecondTry( );
            System.out.println("Enter data on the Species of the Month:");
            speciesOfTheMonth.readInput( );
            speciesOfTheMonth.writeOutput( );
            int futurePopulation = speciesOfTheMonth.predictPopulation(10);
            System.out.println("In ten years the population will be " +
                                futurePopulation);
            //Change the species to show how to change
            //the values of instance variables:
              speciesOfTheMonth.name = "Klingon Ox";
            speciesOfTheMonth.population = 10;
            speciesOfTheMonth.growthRate = 15;
            System.out.println("The new Species of the Month:");
            speciesOfTheMonth.writeOutput( );
            System.out.println("In ten years the population will be " +
                                speciesOfTheMonth.predictPopulation(10));
    //I've add this below
             speciesOfTheMonth.averageLifeSpan( );
             System.out.println("The average life span of the " +speciesOfTheMonth.name +" is " +speciesOfTheMonth.average);
    }

    SpeciesSecondTry.java
    import java.util.Scanner;
    public class SpeciesSecondTry
        public String name;
        public int population;
        public double growthRate;
        public void readInput( )
            Scanner keyboard = new Scanner(System.in);
            System.out.println("What is the species' name?");
            name = keyboard.nextLine( );
            System.out.println("What is the population of the species?");
            population = keyboard.nextInt( );
            System.out.println("Enter growth rate (% increase per year):");
            growthRate = keyboard.nextDouble( );
        public void writeOutput( )
             System.out.println("Name = " + name);
             System.out.println("Population = " + population);
             System.out.println("Growth rate = " + growthRate + "%");
         Returns the projected population of the calling object
         after the specified number of years.
        public int predictPopulation(int years)
              int result = 0;
            double populationAmount = population;
            int count = years;
            while ((count > 0) && (populationAmount > 0))
                populationAmount = (populationAmount +
                              (growthRate / 100) * populationAmount);
                count--;
            if (populationAmount > 0)
                result = (int)populationAmount;
            return result;
    //I've added averageLifeSpan as a double below.
        public double averageLifeSpan()
                   Scanner keyboard = new Scanner(System.in);
                   System.out.println("What is the average life span of the " +name + " species?");
                   double average = keyboard.nextDouble( );
                   return average;
    }

  • Mac pro start up trouble , 5 important questions!!

    I went on a 2 week holiday where my mac pro dual core was unplugged. When I got back and started the system it would go to the desktop screen but would then either freeze or I would get red lines across the display. I would have to manually shut it down and restart till it worked normally.
    So far I have reset the SMC, the PRAM/Nvram, I have replaced the computer battery, run Norton Anitvirus, run a apple Hardware test (it came back fine) I have run Disk Warrior and Tech Tools Pro 5 and I have done an OS X archive and install and nothing has changed.
    Although today the first 2 times I turned it on there was no start up chime/black screen and it took 5 manual restarts to work!
    Question 1: Should I do a fresh install?
    Question 2: Trouble with the first question is that my Super Duper copy was made after the problem started - won't the problem just be transferred?
    Question 3: Does migration assistant transfer my copy to my hard drive if I do a fresh install?
    Question 4: What should I do? - Should I pay for it to be fixed?
    Any help is appreciated!!

    Thank you for the reply.
    Can I ask a few questions as I'm slightly new to computers. I didn't quite get the freshly formatted new drive stuff.
    In my mac pro I have the mac hd with an additional hd and I have one external drive which is my backup (I need to get another one).
    Q1. Unfortunately my backup was made after way the trouble started so a fresh install and migrate won't help will it?
    Q2. Because of this I was thinking of doing a fresh install then just transferring over the music and photos and downloading the software again - would this help?
    Q3. Because of this, I own final cut studio 2 which was then stolen from me, can I just transfer this from my backup (if so how?)
    Q4. How come you recommend uninstalling Norton Anti Virus?
    Q5. If I do a fresh install should I remove my second hd until its done?
    I tried the overnight trick with no luck.
    Thanking you in advance

Maybe you are looking for

  • Report on EWT - Report on tds deducted till issue of tds certificate

    We have implemented ewt recently. we want to have report which will give the tds deducted on advance, invoice , tds challan updation, tds payment, tds certificate issued etc. Do we have any T code which will give the tds details vendor wise for the a

  • Assigning buffer strategy causes app to crash

    I have my first attempt at active rendering. At home it runs fine on my laptop: Vista Home Premium running Eclipse with JDK 1.6 Here at my school library I am running some form of XP (Cannot view system information due to restrictions on student acco

  • Error with dbms_redefinition package?

    Hi everybody! I have a table 'object_log'(it is partioned) . I used dbms_redefinition to change its partion , and evrythink was ok. When I tried to redefine this table for the second time it failed! I run this script BEGIN DBMS_REDEFINITION.start_red

  • How to create an advanced Photo Gallery

    Hello there:   I am designing a web site using Expression Web 4. Which Photoshop product I can use to design and import an advanced photo gallery where pictures are organized in thumbnails then once one hovers with the mouse over a specific picture,

  • How to customize an existing OAF page from Oracle, change it and reload it

    Hello all Oracle Developers, I am having a question regarding to customization, basically I am going to follow a very simple example. We have form: APXVDMVD and OAF web Page AP_APXVDMVD. Applying all our custom code via forms personnalisation is piec