Random numbers in a table

I'm new to java, so please bear with me. What I want to do is create a program which chooses random numbers (between 0-9) in a table, and then presents a diagram of how many of each number comes up.
e.g. if the table size was 10, the output could be something like:
0 *
1 **
2
3 *
9 **
with the stars representing the number of times the number showed up. Any assistance you could provide would be great and appreciated. Thank you

1) Create a Map. The key will be one of the random numbers, the value will be a counter of the number of times the number has been stored.
2) Generate a random number.
3) Place the random number in the map key, and increment the value.
4)Print the random numbers and as many asterisks as the counter values.
I believe this is classwork? Asking about problems in the code that are not working is ok - asking people to write sample code for you is not ok. Part of the assignment requires you to read the documentation and figure out how to write the code.

Similar Messages

  • Generate the random numbers

    How Do I Generate Random Numbers in iWorks
    Excel has the "F9" key to generate random numbers numbers don't
    please see below what i'm trying to do
    I open up a blank Excel worksheet, and type the number "1" into cell A1. Type the number "2" into cell A2. Then type the number "3" into cell A3. Type the number "4" into cell A4, and then type the number "5" into cell A5.
    2
    Type the word "PB" into cell A6.
    3
    Enter the function "=RANDBETWEEN(1,59)" into cell B1.
    4
    Enter an exact copy of this function "=RANDBETWEEN(1,59)" into cells B2, B3, B4, and B5.
    5
    Enter the function "=RANDBETWEEN(1,39)" into cell B6.
    6
    Hit the "F9" key to generate the random numbers simulating game.
    But in numbers how do i do this?
    Thanks!
    Alex...

    firstly your not asking about generating random numbers, your asking how do you make a workbook recalculate new random numbers. From M$'s website:
    F9
    Calculates all worksheets in all open workbooks
    It does not produce random numbers the equations should produce random numbers as soon as you enter them in. If they dont then you have automatic reclaculations turned off and F9 is forcing a recalc.
    In numbers there is not shortcut to forcing the workbook to recalculate other than enter data into a cell. So if you made a new table and then enter data. For every data point you enter you should see new data apear.
    Was just validating the method for forcing and its not working on my ipad. I will mark this conversation and if i find it i will respond again.
    Jason
    Message was edited by: jaxjason

  • How do I generate random numbers from a list of numbers without repeating any number

    I am trying to generate a list of random numbers without any repeating numbers.  For example say the list is from 1 to 15, how do I randomly generate a list of numbers using each number only once?

    pb,
    You can build a randomizer by making a 2-column table with 15 rows. In Column A, Fill with the numbers 1 to 15. In column B Fill with RAND(). Then sort on Column B. There will now be a randomized list of the numbers from 1 to 15 in Column A. You can copy this random list and use it in your application.
    Jerry

  • Please Help in generation of Random Numbers & Characters

    hai friends,
    Please help me to generate random Numbers and Characters to the Fields of the Table.
    Please Send code to it.
    madhava

    It's easier enough. Just use the DBMS_RANDOM package supplied by Oracle.
    SQL> desc rndm
    Name                                      Null?    Type
    COL1                                               NUMBER
    COL2                                               VARCHAR2(10)
    COL3                                               DATE
    SQL> BEGIN
      2     DBMS_RANDOM.initialize(12348765);
      3     FOR i IN 1..4 LOOP
      4        INSERT INTO rndm VALUES (dbms_random.value
      5                                 , dbms_random.string('A', 10)
      6                                 , sysdate + dbms_random.value(1,1000));
      7     END LOOP;
      8  END;
      9  /
    PL/SQL procedure successfully completed.
    SQL> SELECT * FROM rndm;
          COL1 COL2       COL3
    .028766128 pUFMxywBzC 14-JAN-07
      .7524715 SupFLVZmEC 22-JUN-07
    .454116997 EHCEZKPORm 14-FEB-05
    .330733477 gycpybxdRS 12-MAR-07
    SQL> Note that the published API seems to have changed in 9.2 (if not earlier), with the apparent sole purpose of DBMS_RANDOM being the generation of random numbers. However, as you can see, the old methods still work. Not sure what Oracle are up to.
    Cheers, APC

  • FPGA 20 random numbers

    Hello,
    I have NI PXIe-7966R FPGA module and i want to generate 20 random numbers with specified distribution. Now i have random number generator with uniform distribuiton and i have quantile function for my distribution in the form of 1000 point array. It takes a lot of logical blocks of FPGA if Im trying to solve this problem with 20 lookup tables or 20 memory blocks with my quantile function. Can you help me to advice?

    Theres an example on NI.com that uses the method outlined in this paper from xilinx. 

  • I am trying to generate an array of 30 random numbers. after every 5 readings a new vi should open and tell the user that 5 readings has been completed. and again carry on with the generation of array.

    since i do not have a transducer now, i am currently generating an array of 30 random numbers. after every 5 readings a warning should be given to the user that 5 readngs are complete. this cycle should repeat. the array size is 30.
    please help me out,  waiting for reply asap.
    once i have the transducer, i will be taking 30 analog samples and then after every 5 smaples that wraning will be displaye din a new VI
    Solved!
    Go to Solution.

    Use a while loop with a time delay representing your sampling period.
    Use the count terminal to check if equals 4, so 4th iteration=5th sample.
    Use a case structure. The true case will only be executed on the 4th iteration.
    In the true case place a subVI  with your desired message in the front panel. Go to the VI properties window and set "open front panel when called".
    The closing condition of the warnign is not giving in your description.
    Consider that rather than usign a subvi for this, you could use the "One/Two/Three button dialog" or "display message" vis at the "dialog and user interface" pallete.
    Please give it a try and send your own VI. Do not expect us to provide a working solution.
    Regards,

  • How can you generate Multiple random numbers from 1 to 49?

    I am very new at programming with the iPhone SDK and I need some help with a project I am working on. What I want to do is set up a window with 6 labels and 1 button. When the user clicks the button, the program will populate 6 randomized numbers each ranging from 1 to 49, and then place each of 6 numbers in a label. But each time the program ends and starts again the numbers cannot be the same, and also when the user clicks the button, no label can have the same number twice, so for example. If label 1 had the number 10, the other 5 labels cannot have that number until the button is clicked again. I know how to set up the interface, I just need the code. I would so greatly appreciate someone's help in this matter. I have been trying to do this for days and I cannot figure it out. Possibly someone who knows tons about Objective C programming can help me!
    Thank-you so very much!!

    I see that you're writing a lottery number generator. Perhaps the easiest way to do it is to emulate a real lottery: fill an array (NSMutableArray, probably) with the numbers between 1 and 49, pick one at random, remove that number from the array, and repeat. (You can think of the numbers as being the balls and the array as being the machine that pops them out.)
    One simple way to get the random indices needed is to extract six random bytes from Randomization Services using SecRandomCopyBytes, then loop over them, using the modulo operator (%) to select an index within the size of the array.
    And no, I'm not going to write your code for you. If I was going to do that, I could package and sell the app myself.

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

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

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

  • Problem with Purchase Order creation with Random numbers .

    Hi Experts
    Currently i am facing an issue with Bapi BAPI_PO_CREATE1 to create Purchase order with random numbers for example items 1, 3,5.
    Please let me know the settings .
    Thanks in Advance

    Hi Neha,
    A reset of the release strategy only takes place if
    -  the changeability of the release indicator is set to '4' in
       case of a purchase requisition and '4' or '6' in case of
       another purchasing document (purchase order, request for
       quotation, contract, scheduling agreement),
    -  the document is still subject to the previous release
       strategy,
    -  the new TOTAL NET ORDER VALUE is higher than the old one.
    The total net order value is linked to CEKKO-GNETW for a purchase order,
    CEBAN-GSWRT for a purchase requisition item-wise release and CEBAN-GFWRT
    for a purchase requisition overall release.
    If you have maintained a Tolerance for value changes during release
    (V_161S-TLFAE), the release strategy is reset when the value of the
    document is higher than the percentage you have specified and if the
    document is still subject to the previous release strategy.
    Review the SAP note 365604 and 493900 for more
    information about Release strategy.
    Regards,
    Ashwini.

  • Adjusting page numbering in the Table of Contents

    I have a question regarding adjusting page numbering in the table of contents. I have manually adjusted my page numbering to start at page 3, which is now called page 1. But my table of contents still show this page as page 3, while I want it to be shown as page 1.
    How do I do this?
    I tried to find an answer somewhere on this forum, but I couldn't find one. Neither could I find a solution in the help file.
    I hope you understand my question. I also included the document, which might be of help. Thank you!

    This answer assumes that your document uses the Default page style for physical pages 1-3. You are going to need two different page styles to accomplish what you want. (I'm guessing you have used a page number offset of -2 to get your physical page 3 numbered as 1 and this simply will not work in the TOC.)
    Put your cursor in the Title page (physical page 1) and open the Stylist (F11). Click the Page icon (4th from left) then click the New Style From Selection icon (2nd from right). Give it a name like 'Body'. Before you close the Stylist double click on Default just to make sure you did not change the style of the 1st page.
    While you are still on the 1st page click into the footer and remove the page number field assuming you do not want it.
    Put you cursor in the FIRST (1st) paragraph of the 3rd page and do **Format > Paragraph > Text Flow tab. In the Breaks section, check the Enable box, if not already checked, then check the With Page Style box, select the Body style from the drop down menu and set the page number to 1.
    If the page number field is still in the footer on this page then delete it and insert it again. It should now show 1.
    Click into the TOC, right click and select Update Index/Table.
    Just in case you have trouble translating this to your version of SO I have fixed your document and have attached it.
    * *To change to a new page style while writing your document do Insert > Manual Break > Page Break and select the new style. If you want a new page number you can check that box and set the new number.  

  • Program to create random numbers in plsql

    How do we Write a program to create random numbers.
    Thanks

    No need to - we have DBMS_RANDOM :)

  • HELPwith array of random numbers!!!

    can anyone please write up a program that uses an array of random numbers from 0-100 and sort them out...
    if anyone can help me that would be great...i tried but i cannot figure it out...
    please just write the program so I just have to copy and paste :)

    This has to be the most asked question here, or at least it's way up there with classpath and path questions.
    Use the search feature to search the forum for random number generation and I swear you'll find more answers and code than you could possibly want.
    Good luck
    Lee

  • Can't validate outlook on iPad - random numbers and letters don't display - only a question mark in a blue box

    If I have to validate Outlook on PC or Mac - I have no problem - the random numbers and letters display fine - but if I am requested to validate outlook before sending a mail when using my iPad, the operation fails as the test numbers and letters are not shown - only a snap blue box with a question mark.  How do I convert the box into the image of a new validation code?  Thanks in advance.

    Hello,
    The question mark means it can't find it where it was when you put it in the Dock.
    I'd get EasyFind...
    http://www.macupdate.com/info.php/id/11076
    Use it to search your whole drive for Files & Folders, case insensitive & show invisibles...
    Complete
    That will show any with that word in the name at all.

  • Random letters to random numbers in the code template?

    I'd like to change the random letters of the code template in Motion 5 to be random numbers.
    PLATFORM: quad 2.9 macpro, Mavericks, 8 GB RAM, Motion 5.

    type the number you want. I highly recommend a monospace font (or at least a font with monospace number characters -- there are a few...)
    Add > Behaviors > Text Animation
    Parameter Add > Format > Character Offset
    Set Character Offset to 18 (seems to work well.)
    Character Set: Preserve Case & Digits
    Adjust Spread to taste.
    Consider Direction > Random

  • Random numbers in arrays

    i have been faced with a new problem, i have to generate a random number (between 0-63) of random numbers (between 0-63).
    Can i do this all in one array to randomly generate an array containing the random number of elementnts and set each of the elemnt to a random value.
    Random x = new Random();
    int j= x.nextInt(63);
    String [j] numbers;
    Random q = new Random();
    for(j=0, j<=numbers.length, j++)
       int f= q.nextInt(63);
      numbers[j] =f;
    } I had an idea of doing something like the code above can any see a better way to do it.

    I am getting this error
    java.lang.ArrayIndexOutOfBoundsException: 15
    from
    numbers[z] = rng.nextInt(63);i think this is because i am randomly calling the method, so it runs through it once but the second time it flags up the error.
    void Randm()
                         Random rng = new java.security.SecureRandom();
                    int o = rng.nextInt(63);//I hope you know this is zero to 63 exclusive, i.e., it can't return 63
                    int [] numbers = new int[o];
                    for(int z = 0 ; z <= numbers.length ; z++)
                        numbers[z] = rng.nextInt(63);// again, this will not return 63
                        System.out.println("ran gen "+numbers[z]);
    }I think it may be the way i am declaring the array, can anyone shed some light on the situation.

Maybe you are looking for

  • Refresh Table Data after dialog window is closed.

    My JDeveloper version is 11.1.1.6.0 I have a master-detail scenario where in Master records(Table Component) are displayed in top half of the splitter panel. Detail records are displayed in second half of the splitter control using table components p

  • Can't drag-and-drop from CD to Desktop

    I can't drag-and-drop a photo from an Iphoto CD to the Desktop. I was able to do this on my old 17"IMAC. But the new 20" won't allow me to this anymore. Once I drag it past the Iphoto window the cursor has a circle with a bar across. The MAC person a

  • Cannot mount root during Solaris install on SPARCengine ULTRA axi

    I use boot cdrom which sucessfully formats swp partition and copies files to hd. But then when I reboot I get the following: SPARCengine(tm)Ultra(tm) AXi (UltraSPARC-IIi 440MHz), PS/2 Keyboard OpenBoot 3.10.10 ME, 512 MB memory installed, Serial #106

  • When crystal report is going to support 64 native application

    You said in the below article that Crystal Reports 2008 (version 12.1.x) support 64 bit Operating systems, but in a 32 bit mode only. When it going to support in 64 bit mode ( native 64 bits support) http://www.sdn.sap.com/irj/boc/index?rid=/library/

  • Weblogic server- some basic questions

    Being new to Weblogic, I want to know the best practices for following: I am dealing with WLP(weblogic Portal server) 10.3.2. I need expertise of guys on this forum. 1. I have setup a Dev server with WLP and am currently starting WLP with /domains/ba