Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Processing In the provided incomplete program, there are two arrays, targe

ID: 3545891 • Letter: U

Question

Using Processing                 

                    In the provided incomplete program, there are two arrays, target and array. target                 

                    is lled with some given numbers, which you do not need to change.                 

                    (a) Fill array with random numbers in the range between 1 and 100 using the built-in                 

                    subroutine random.                 

                    (b) Output both target and array.                 

                    (c) For each element of target, output all the numbers in array that are larger than                 

                    this number.                 

                    Skeleton Code (only add code where it says, no editing code in skeleton)                 

                    int[] array = new int[10];// input array
                    int[] target = new int[4];// target array
                    PFont myFont;
                    int hOffset, vOffset, hSpacing, vSpacing;
                    // Declare variables that you may need below                 

                    void setup()
                    {
                    size(1000, 300);
                    smooth();
                    myFont = createFont("FFScala", 28);
                    textFont(myFont);
                    textAlign(LEFT);
                    target[0] = 2;
                    target[1] = 20;
                    target[2] = 50;
                    target[3] = 88;
                    hSpacing = 40;
                    vSpacing = 40;
                    // initialize array with random numbers in the range from 1 to 100.                 

                    }                 

                    void draw()
                    {
                    background(255);
                    fill(0);
                    hOffset = 50;
                    vOffset = 50;
                    // add code below to display target                 

                    // add below below to display array                 


                    // add code below to display numbers larger than each value in target                 


                    }

Explanation / Answer

int[] array = new int[10];// input array

int[] target = new int[4];// target array

PFont myFont;

int hOffset, vOffset, hSpacing, vSpacing;

// Declare variables that you may need below


void setup()

{

size(1000, 300);

smooth();

myFont = createFont("FFScala", 28);

textFont(myFont);

textAlign(LEFT);

target[0] = 2;

target[1] = 20;

target[2] = 50;

target[3] = 88;

hSpacing = 40;

vSpacing = 40;

// initialize array with random numbers in the range from 1 to 100.


for(int i=0;i<10;i++)

array[i]=random(1,100);//random function


}


void draw()

{

background(255);

fill(0);

hOffset = 50;

vOffset = 50;

// add code below to display target



for(int j=0;j<4;j++)

println(target[j];


// add below below to display array



for(int i=0;i<10;i++)

println(array[i]);

// add code below to display numbers larger than each value in target


//below code is to display each element of array[] which is greater than the target[] each element


for(int k=0;k<4;k++)

{


println(target[k]);

println(":");


for(int l=0;l<10;l++)

{

if(target[k]<array[l])

println(array[l]);

}


}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote