Question: In the program below I need to calculate distance with speeds and values coming from a 2d array. Once I get the result of calculation,
In the program below I need to calculate distance with speeds and values coming from a 2d array. Once I get the result of calculation, the program should search such calculation and return a list of speed and angle combinations
I need figuring out the logic for how to search the calculation and retuning a list of speed and angels. Below is the method where I'm attempting to search the calculation and return a list of speed and angel. Also, I attach a screen shot of the whole class.
public void winingSpeedAndAngel(int minValue, int maxValue) {
// if range between min and max return speed and angel
double range = trajectoriesCalculations();
if(range >= minValue && range
// print speed and angels use to calculate this range
int [] [] table = speedNAngels( speedsArray, numOfSpeed, angelsArray,numOfAngels);
System.out.println();
}else{
System.out.println("no viable values");
}

class CatapultContest {
private int numberOfSets = 0;
private int numOfSpeed = 0;
private int numOfAngels = 0;
private int [] speedsArray;
private int [] angelsArray;
private int minValue = 0;
private int maxValue = 0;
CatapultContest (int numberOfSets,int numOfSpeed, int numOfAngels, int[] speedsArray, int [] angelsArray, int minValue, int maxValue ) {
this.numberOfSets = numberOfSets;
this.numOfSpeed = numOfSpeed;
this.numOfAngels = numOfAngels;
this.speedsArray = speedsArray;
this.angelsArray = angelsArray;
this.minValue = minValue;
this.maxValue = maxValue;
}
public int[][] speedNAngels( int [] speedsArray, int numOfSpeed, int [] angelsArray, int numOfAngels) {
int [][] speedAngels = new int [numOfSpeed][numOfAngels];
int row =0;
int col =0;
for(row = 0; row
speedAngels[row][0] = speedsArray[row];
}
for(col = 0; col
speedAngels[col][1] = angelsArray[col];
}
return speedAngels;
}
public double trajectoriesCalculations() {
int [][] speedAndAngels = speedNAngels(speedsArray, numOfSpeed, angelsArray, numOfAngels);
double range = 0.0;
for(int i =0; i
int speed = speedAndAngels[i][0];
int angel = speedAndAngels[i][1];
double gravity = 9.8;
double cA = Math.toRadians(angel);
range = (Math.pow(speed, 2)) * Math.sin(2*cA)/gravity;
}
return Math.floor(range);
}
public void winingSpeedAndAngel(int minValue, int maxValue) {
// if range between min and max return speed and angel
double range = trajectoriesCalculations();
if(range >= minValue && range
// print speed and angels use to calculate this range
int [] [] table = speedNAngels( speedsArray, numOfSpeed, angelsArray,numOfAngels);
System.out.println();
}else{
System.out.println("no viable launch");
}
}
}
class CatapultContest { private int nutbrotto - private int nuntDfSpeed = 8; private int nun fangels = 0; pravate int ( speedsArray pravate int I) angelsArray private int nivalue = 0; private int naxValue = 0; CatapultContest (int nunberotsets, int nuncf5peed, int nur Angels, int[] speedsArray, tot [l angelsarray, int nirvalue, int Yax! this.minbertsets - nunherit Sets this.munofspand = null Speed: this.nunnfangels = nurofangels; this.speedsArray = speedsArray: this.angelsArray - engelsArrayi this.inValue = minValut this. TaxValue = taxValue } public int 121) SpeedAngelsint [l spredsArray, ant nuntSporo, int [langelsar ray, int numotAngels) { int [] [] speedAngels = new int inundfspeed] [rutofangels): int row=; int col =8; forcrow = 6; row
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
