Random numbers in sumproduct function

  have no success with this:     e33 has 1,  f33 has 2,  g33 has 3.    k22 has 4,  k25 has 5,  k32 has 6.       expecting (1x4) + (2x5) + (3x6) = 4+10+18= 32
    it's the outer product in matrix algebra.     in apl it's 1 2 3 +.x 4 5 6 = 32       
     how is a random list or range  of  values entered?     thanks.     don mattern

I could be wrong, but I do not believe numbers has the power to make matrix calculations.  I might suggest excel if that is an option.
This is how I would say that you need to do matrix multiplication.  I am going to assume you know all the rules for multiplying matrices.  First you need to have 4 separate tables with no header rows, no footer rows, nor header columns.
I will demonstrate with a (3x3)(3x3).  The first two tables are the Matrices that you are multiplying.
1
2
3
4
5
6
7
8
9
9
8
7
6
5
4
3
2
1
The third is the Transpose of Table 2.  In row 1 column A, place this formula =INDEX(TRANSPOSE(Table 2::$A$1:$C$3),ROW(),COLUMN()), and then fill it all the way out. And this is your result:
9
6
3
8
5
2
7
4
1
Now in the fourth table, in row 1 column A place this formula: =SUMPRODUCT(OFFSET(Table 1::$A$1,ROW()−1,0,1,3),OFFSET(Transpose of Table 2::$A$1,COLUMN()−1,0,1,3)) and fill out to the rest of the table.
30
24
18
84
69
54
138
114
90
This is a slight doozy, but I will explain when I have it written up in a few.

Similar Messages

  • How to generate unique random numbers

    Hi All,
    I am wondering whether there is already a random library or built-in function available in Java to produce some random numbers between certain ranges that are not repetitive. Let's look at a common examples as follows:
    Random diceRoller = new Random();
    for (int i = 0; i < 10; i++) {
      int roll = diceRoller.nextInt(6) + 1;
      System.out.println(roll);
    }My understanding from this approach is that it allows the same number to be repeated over and over again. However, I would like to find out how to continue generating random numbers from remaining ones that haven't been generated earlier.
    Using the above example to illustrate my intention:
    1st random number generated - possibility of 1 - 6 showed up. Say 5 is picked.
    2nd random number generated - possibility of 1, 2, 3, 4, 6 only. Say 2 is picked.
    3rd random number generated - possibility of 1, 3, 4, 6 available. Say 1 is picked.
    4th random number generated - possibility of 3, 4, 6 left. Say 6 is picked.
    5th random number generated - possibility of 3, 4 remains. Say 4 is picked.
    Any assistance would be much appreciated.
    Many thanks,
    Jack

    htran_888 wrote:
    Hi All,
    I am wondering whether there is already a random library or built-in function available in Java to produce some random numbers between certain ranges that are not repetitive. Let's look at a common examples as follows:
    Random diceRoller = new Random();
    for (int i = 0; i < 10; i++) {
    int roll = diceRoller.nextInt(6) + 1;
    System.out.println(roll);
    }My understanding from this approach is that it allows the same number to be repeated over and over again. However, I would like to find out how to continue generating random numbers from remaining ones that haven't been generated earlier.
    Using the above example to illustrate my intention:
    1st random number generated - possibility of 1 - 6 showed up. Say 5 is picked.
    2nd random number generated - possibility of 1, 2, 3, 4, 6 only. Say 2 is picked.
    3rd random number generated - possibility of 1, 3, 4, 6 available. Say 1 is picked.
    4th random number generated - possibility of 3, 4, 6 left. Say 6 is picked.
    5th random number generated - possibility of 3, 4 remains. Say 4 is picked.
    Any assistance would be much appreciated.If it is your school assignment then you have the answer above (List & the lists length).
    (You might want to look at Collections)

  • 6 random numbers without repeat

    I'm trying to make a 6 digit random number generator between 1 and 48. When the user click a button 6 random numbers show up in 6 different textFeilds. The problem is that I don't want the same number twice. How can I generate 6 different random numbers without using return and breaking out of the function?
    import flash.events.Event;
    stop();
    btn.addEventListener (MouseEvent.CLICK, random1);
    function random1 (evt:Event) {
              display1.text = "";
              display2.text = "";
              display3.text = "";
              display4.text = "";
              display5.text = "";
              display6.text = "";
              var r1 = Math.floor(Math.random()*(1+48-1))+1;
              var r2 = Math.floor(Math.random()*(1+48-1))+1;
              var r3 = Math.floor(Math.random()*(1+48-1))+1;
              var r4 = Math.floor(Math.random()*(1+48-1))+1;
              var r5 = Math.floor(Math.random()*(1+48-1))+1;
              var r6 = Math.floor(Math.random()*(1+48-1))+1;
              if (r2 == r1 || r3 == r2 || r4 == r3 || r5 == r4 || r6 == r5) {
                        return;
              var liste:Array = new Array();
              liste.push(r1,r2,r3,r4,r5,r6);
              liste.sort(Array.NUMERIC);
              display1.text = String(liste[0]);
              display2.text = String(liste[1]);
              display3.text = String(liste[2]);
              display4.text = String(liste[3]);
              display5.text = String(liste[4]);
              display6.text = String(liste[5]);

    Here's the code for the approach mentioned with your textfields included
    btn.addEventListener (MouseEvent.CLICK, random1);
    function random1 (evt:Event) {
        var nums:Array = new Array();
        // fill the array of numbers
        for(var i:uint=1; i<=48; i++){
            nums.push(i);
        shuffle(nums);
        // grab the first six in the shuffled array
        var liste:Array = nums.splice(0,6);
        // assign the values to the textfields
        for(var j:uint=1; j<=6; j++){
            this["display"+String(j)].text = String(liste[j]);
    function shuffle(a:Array) {
        var p:int;
        var t:*;
        var ivar:int;
        for (ivar = a.length-1; ivar>=0; ivar--) {
            p=Math.floor((ivar+1)*Math.random());
            t = a[ivar];
            a[ivar] = a[p];
            a[p] = t;

  • 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 can I generate multiple unique random numbers?

    Hello,
    I am trying to generate multiple random numbers between a given set of numbers (1-52) and not have the same number generated twice within that set. I can compare the last and next numbers with the compare function but how would I go about comparing all of the generated numbers without using a huge list of shift registers...
    Any help/ideas are welcome and appreciated.
    Jason
    Solved!
    Go to Solution.

    Here is an implementation of Jason's solution.
    steve
    Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
    question. Give "Kudos" to replies that help.
    Attachments:
    random.vi ‏10 KB

  • Generate multiple random numbers?

    Hi,
    I'm trying to generate random numbers using Math.random()* n;
    but I want the random numbers to reset to something different after
    a particular event is called. Instead, I've noticed the numbers
    either buzz away randomly in every frame (when placed inside
    onEnterFrame), or it picks random numbers once, and then uses those
    same values over and over (when placed outside the onEnterFrame).
    How do i get actionscript to generate new random numbers
    after each myMC.onPress = function(), or alternatively, after a
    score changes (like some kind of watch feature?)

    ok, i've got a half working version;
    function ranbot(x) {
    return Math.ceil(Math.random()* x) + "/" +
    Math.ceil(Math.random()* x);
    trace(ranbot(60));
    but is it possible to set up the function so the numerator is
    equal to or less than the denominator? Also, if the numerator is
    set to never exceed the denominator, then a large percentage -
    something like 25-50% of the output fractions would equal "1", like
    55/55, 23/23, 7/7, 28/28, and so on.
    I did something like this when using variables;
    var randombot2:Number = Math.ceil(Math.random()* 99);
    var randomtop2:Number = Math.min(randombot2 -
    Math.floor(Math.random()* randombot2* 0.5),
    Math.ceil(Math.random()* 99));
    - but I do not understand how this works in function
    terminology.

  • How do I generate an array of random numbers that relate to an output wave that falls within a certain frequency range?

    I have been creating random numbers that I'm using within a system, the system is working fine, but now I have realised that the random numbers must be outputted to speakers in such a way as to filter out all but a low frequency range.
    I was thinking about generating a dither signal with a bandpass filter, but could not get it to give me out a full array of 250 values which I could then manipulate.
    The sampling frequency of the output is 200Hz and the 250 data points must fall within the 0-100Hz range.
    Another course of action I am considering is to use an FFT and an inverse FFT to get the data that I'm looking for, but I'm fair
    ly inexperienced with using labVIEW and can't quite get it to work.
    Thanks for the help,
    Hank.

    As you may already know, in the Functions palette/Analysis VIs/Filters VIs are VIs for filtering. There are also some examples for using these filters under Examples/Analysis/fltrxmpl. You may find some of these are related to your situation, especially for filtering out the higher values.
    An option is to simply output the random values to a Comparison/"less than or equal" function, where only values <= to 100 would be sent to an array which is in a For loop. Use the iteration counter of the For loop to count up to 250, at which time you would pass the whole array to your next node. This would let you have 250 values between 0 and 100 for your final array.
    Good luck.

  • Array of unique random numbers - help?

    basically, i'm trying to create a BINGO card.
    i stared learning Java a week ago and am finding it easy to learn and use....at least so far.
    my instructor gave me the assignment to created a BINGO card. so i used the system.out.format command to make 5 tab fields, 8 spaces each ("%8s %8s %8s %8s %8s", "B", "I", "N", "G", "O"). although the assignment only wanted me to think numbers out of thin air, just to use as examples, i went above and beyond with the idea to make a BINGO card generator that could actually function.
    then i started the random number sequences, using the Math.random() command. all told, there are 24 of these in the program, one for each number on a bingo card. the field in the middle is the FREE space, so it has no Math.random command.
    in BINGO, each letter (one of my five tab fields) can have a number in ranges of 15. B is 1 to 15, I is 16 to 30, etc. it looks similar to this:
    B I N G O
    9 19 39 57 66
    3 28 32 51 74
    3 29 FREE 46 70
    14 28 43 55 67
    9 24 35 59 62
    as you can tell, i'm having trouble with actually making unique random numbers so that none repeat.
    is there a command or string or something to help me accomplish this?

    The best way I've come up with is to use an object to store the numbers that implements Collection--like ArrayList...
    Then you load it with the range of numbers that you want and call, shuffle() on the object, that will randomize your range of numbers and then you can choose the quantity you want from the storage object. So let's say you need 25 number in the range of 1 to 100:
    Add the numbers (you have to use classes so I would do Integers) 1 to 100;
    call shuffle()
    pull back the first 25 numbers
    This will guarantee that each number is distinct and in a random order.
    If you need multiple sheets populated, you can just call shuffle() between population of each sheet.
    package Junk;
    import java.util.ArrayList;
    import java.util.Collections;
    class Junk{
      private ArrayList<Integer> l;
      Junk(){
        l = new ArrayList<Integer>();
      public void loadList(int s, int e){
        for(int i=s; i<=e; i++){
          l.add(new Integer(i));
      public void randomizeList(){
        Collections.shuffle(l);
      public void printList5(){
        for(int i=0; i<5; i++){
          System.out.println(l.get(i));
      public static void main(String[] args){
        Junk j = new Junk();
        j.loadList(10,99);
        j.randomizeList();
        j.printList5();
        System.out.println();
        j.randomizeList();
        j.printList5();
    }

  • Figuring out the occurence of random numbers?

    So, I'm taking this Computer Science class, and I've been struggling so much with today's lesson.
    For this particular question, I have to get 20 random numbers between 1-5, represent them in text format, and the show how often each of the numbers occured. I've done the first two of the three parts, but this last part really has me stumped..
    (Note: I'm using Ready to Program by Holt.... so I'm using their console)
    Here's the code I got so far:
    import java.util.*;
    import hsa.Console;
    import java.io.*;
    public class RandomNumbers
        static Console c;
        static public void main (String[] args) throws IOException
            c = new Console ();
            int a;
            Random generator = new Random();
            c.println("Generating Numbers: ");
            for(a=1;a<=20;a++)
                int r = generator.nextInt(5)+1;
                    switch(r)
                         case 1: c.print("One",10); break;
                         case 2: c.print("Two",10); break;
                         case 3: c.print("Three",10); break;
                         case 4: c.print("Four",10); break;
                         case 5: c.print("Five",10); break;
    }}

    I had a similar assignment my last semester for C++. I would think the general idea is the same.
    Here I declare an Array. Then I store the values of the dice rolled in the array and display it on the screen. The syntax will be different since you are not using C++.
    #include <iostream>          // preprocessor directive
    #include <ctime>          // preprocessor directive
    #include <cmath>          // preprocessor directive
    #include <cstdlib>          // preprocessor directive
    using namespace std;     // enables preprocessor directives
    int random_int(int a, int b);          // function prototpye
    int main ()     // main function
         srand(time(NULL));          // enables random numbers to be generated
         int d1, d2, sum;                         // declaring variables
         int a[10] = {0,0,0,0,0,0,0,0,0,0};     // initializes valus in array to 0
         int roll;                                   // declaring variable
         cout << "Roll how many times?";          // ask number of times to roll dice
         cin >> roll;                              // get number of times to roll dice
         for(int i=0; i<=roll; i++)               // to roll the dice the numbers or times asked
              d1 = random_int(1,6);               // generates number for die 1
              d2 = random_int(1,6);               // generates number for die 2
              sum = d1 + d2;                         // adds the two dice together     
              if(sum == 2)                         // increase value in array  by 1 that corresponds to 2
                   a[0]++;
              else if(sum==3)                         // increase value in array  by 1 that corresponds to 3
                   a[1]++;
              else if(sum==4)                         // increase value in array  by 1 that corresponds to 4
                   a[2]++;
              else if(sum==5)                         // increase value in array  by 1 that corresponds to 5
                   a[3]++;     
              else if(sum==6)                         // increase value in array  by 1 that corresponds to 6
                   a[4]++;
              else if(sum==7)                         // increase value in array  by 1 that corresponds to 7
                   a[5]++;
              else if(sum==8)                         // increase value in array  by 1 that corresponds to 8
                   a[6]++;
              else if(sum==9)                         // increase value in array  by 1 that corresponds to 9
                   a[7]++;
              else if(sum==10)                    // increase value in array  by 1 that corresponds to 10
                   a[8]++;          
              else if(sum==11)                    // increase value in array  by 1 that corresponds to 11
                   a[9]++;
              else if(sum==12)                    // increase value in array  by 1 that corresponds to 12
                   a[10]++;
         for(int j = 2; j<=12; j++)                    
              cout << j << "  " << a[j-2] <<endl;          // output the array
         return 0; //exit program
    int random_int(int a, int b)          // used to generate te random numbers
         int random = rand()%(b-a+1) + a;
         return (random);
    }          

  • How to generate random numbers that doesnt contain characters?

    How do we generate random numbers in ESB ROuting Service/ XSL transformation that does not contain characters. I have been using "orcl:generate-guid()" , but it contains some characters, so, I substring it to get only numbers. I dont want to take this risk and in future, my substring itself may contain characters.
    Has anybdy tried this before?
    Thanks,

    If the goal is to have a pseudo random number then consider using the translate function to replace the occurances of the A - E characters with another digit. For example:
    translate(orcl:generate-guid(),'0123456789ABCDEF','0123456789123456')
    This will produce a 1 for A, 2 for B, etc. While not a valid hex to decimal conversion of the GUID value, it does get around the hex issue and might be sufficient for your purposes.
    I would perform a large sample test to see just how unique the values end up being.
    As for why hex is used, well GUID's are most commonly written in text as a sequence of hexadecimal digits such as: 3F2504E0-4F89-11D3-9A0C-0305E82C3301. i.e. 128 bits represented in 32 characters formatted into 5 sections.
    Hope this helps,
    Peter

  • Random Numbers Question

    I'm working from a chapter in Gary Rosenzweig's
    ActionScript 3.0 Game Programming University. In this
    example 36 random cards are created and placed on the stage. I
    understand most of the code except for this line:
    thisCard.cardFace = cardList[r]; The line above the one I
    just mentioned assigns a random value to r and I don't understand
    how the computer knows it's not assigning a value to cardFace that
    already exists? Since this function is iterating several times
    wouldn't it be possible for one of the random numbers to be
    repeated?
    Joe

    yes, one card is deleted. that card is thisCard.cardFace.
    it's just like dealing cards. when you deal an ace of clubs
    to someone, that card is removed from the deck. any card dealt
    after that is randomly selected from the remaining cards.
    the code above is more akin to organizing a deck of cards
    with the ace of clubs on top, king of clubs beneath, queen of
    clubs,...,2clubs,ace of diamonds,...,2diamonds,...,2spades. then
    pick a random number between 1 and 52, select that card number and
    remove it from the deck. now pic a random number between 1 and 51
    and remove that from the dect. etc.

  • 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.

Maybe you are looking for

  • IPad rotate webpage to landscape OVERsizes page to larger than screensize

    I have a responsive website, that tests fine on older models of ipad/iphone. But on the new ios/Safair (5.1.1), the page looks fine on portrait mode. Rotate it to landscape and the website resizes too large for the actual browser window and enlarges.

  • Content repository-401 not able to create

    SAP experts, When i try to create a content repository i am getting this 401 error. I enter in through OAC0 gave the server details taken from basis moved to CS admin. it takes to create section when i click on create it asks for log in and later giv

  • Possible to use both Front Row AND Media Central with same Apple Remote?

    Dear Fellow Mac Users, I have just got a copy of Media Central as i want to use it to view movie files with due to its great codec support. however due to its slightly sluggish and cumbersome design i'd like to continue to use front row for my itunes

  • Papi WS not working

    Hi, I'm using OBPM 10.3.2 on WLS 10.3.3. When I try to deploy the PAPI WS ear I get an error like: weblogic.wsee.ws.init.WsDeploymentException: The WebLogic Server 9.x-style policy is not supported in JAX-WS web services. So according to this thread

  • ESS Address Change

    My client is implementing ESS in R/3 4.6 and portal 6 Currently we are implementing Address Change functionality. The issue is: In R/3 Address Infotype for US we are not using the field ’County’, and it is enabled. But we are getting this field in po