#source code for first one:
import java.util.Scanner;
import java.lang.*;
class Sample{
public static int oddNumCount(int data[]){ //function declaration
int count=0;
for(int i=0;i<data.length;i++){ //iterate over each element in the array
if(data[i]%2==0){ //check element is odd or not
if(data[i]>65 || (data[i]>=20 && data[i]<=35 )){ //f element is odd than it chech condion
count=count+1; //increment the count value by 1
}
}
}
return count;
}
public static void main(String args[]){
int data[]={34,56,78,98,37,49,27,28,29,30}; //array intialization
int oddcount=oddNumCount(data); //call the method
System.out.println("Odd number count:"+oddcount); //print the oddcount in the array
}
}
#source code along with output:
#second one source code such as formula expression:
import java.util.*;
import java.lang.*;
class Sample{
public static void main(String args[]){
double y=2,z=3; //here y and z values are initialized
double val=Math.pow(((Math.pow(y,3)-5)/Math.pow((1-Math.sqrt(z)),10)),2); //ecpression in single line
System.out.println("Value:"+val); //output the value
}
}
#source code along with output:
#if you have any doubt or more information needed comment below..i will respond as possible as soon..if you like give thumbs up...thanks..
a. Write a method that receives (a reference to an array of integers and returns the...
In Java* Write a program that reads an arbitrary number of 20 integers that are in the range 0 to 100 inclusive. The program will ask a user to re-enter an integer if the user inputs a number outside of that range. The inputted integers must then be stored in a single dimensional array of size 20. Please create 3 methods: 1. Write a method public static int countEven(int[] inputArray) The method counts how many even numbers are in...
How to write a recursive method named lessThanKFirst that receives an array of integers a and an integer k and rearranges the integers in a in such a way that all integers that are smaller than k come before any integers that are greater than or equal to k. As an example, suppose that a and k are: int[] a = {35, 12, 57, 28, 49, 100, 61, 73, 92, 27, 39, 83, 52}; int k = 73; Then, the following...
Write a function shuffle that takes an array of 20 integers and then shuffles the integers using the following algorithm. For each element X of the array, generate a random number N between 0 and 19, inclusive. swap X with the element that corresponds to N.
JAVA 1.Write a static method named getMaxEven(numbers) which takes an array of positive integers as a parameter. This method calculates and returns the largest even number in the list. If there are no even numbers in the array, the method should return 0. You can assume that the array is not empty. For example: Test Result int[] values = {1, 4, 5, 9}; System.out.println(getMaxEven(values)); 4 System.out.println(getMaxEven(new int[]{1, 3, 5, 9})); 0 public static int --------------------------------------------------------------------------------- 2. Write a static method...
Write a method called stdev that returns the standard deviation of an array of integers. Standard deviation is computed by taking the square root of the sum of the squares of the differences between each element and the mean, divided by one less than the number of elements. (It's just that simple!) More concisely and mathematically, the standard deviation of an array a is written as follows: stdev(a)=∑i=0a.length−1(a[ i ]−average(a)2)a.length−1 For example, if the array passed contains the values [1,...
In C, write a method that takes in an array of integers and returns its size. Q9]Write a method that takes in an array of integers and returns it's sizel10 points
java code Write a method called reverse that takes an array of integers as an input and returns the same values in reverse order as the output. Test your method in the main.
Write a method that takes an array of ints and that returns true if there are more odd numbers than even numbers. However, as for a casino, 0 is not counted as an odd or an even number. If the array is empty or contains only 0's the method should return false.
Preferred in Java Write a method called print Array With Total that accepts a reference to a two - dimensional array of integers and two primitive integers called number Of Rows and number OF Columns as parameters and displays the elements of two - dimensional array as a table with an extra column for the row total as the rightmost column and an extra row for the column totals as the bottom row. (Please do NOT call either definition of...
Write a function that takes an array of integers as an argument and returns a value based on the sums of the even and odd numbers in the array. Let X = the sum of the odd numbers in the array and let Y = the sum of the even numbers. The function should return X – Y The signature of the function is: int f(int[ ] a) Examples if input array is return {1} 1 {1, 2} -1 {1,...