A) write a public static method called \" calculate \" that will accept three do
ID: 3552126 • Letter: A
Question
A) write a public static method called " calculate " that will accept three double arguments for the values of x, y and z and should return a double value that equals the result of the follwing equation : result = 5 * x + 4 / 7 * ( y - 5 * z);
B) write a do.. while loop that will display the odd number between a rang of numbers provied in the variables lowNumber andhighNumber. The values of these two variables are assumed to be set correctly elsewhere in theprogram. just provied the code for the do..while loop which Preserves the values of these variables.
C) Given an array of 80 integers called myNums, initialize the array so that it contains randomly generated value in the range of
- 35 to +15.
Explanation / Answer
A)
public static double calculate(double x, double y, double z){
return 5 * x + 4 / 7 * ( y - 5 * z);
}
B)
if(lowNumer != highNumber){
int temp = lowNumber;
if(temp%2==0) temp++;
do{
System.out.println(temp);
temp += 2;
}while(temp<=highNumber);
}
else if (lowNumber%2 == 1){
System.out.println(lowNumber);
}
C)
int t;
Random rand = new Random();
for(t=0; t<80; t++){
myNums[t] = rand.nextInt(51)-35;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.