Add Odds Only
Given parameters a, b, c, d, and e, passed into the addOdds() method, do the following:
Declare a List of Integer, you can name the List whatever you want.
Put each parameter into the List as an element, in order from a to e.
Write code that can find the sum of all the odd integers in the List
return the sum of the odd integers
import java.io.*;
import java.util.*;
public class CodingQuestion {
static int addOdds(int a, int b, int c, int d, int e) {
/***** DO NOT CHANGE THE CODE BELOW THIS LINE *****/
// WRITE YOUR CODE HERE
} // end of addOdds()
/***** DO NOT CHANGE THE CODE BELOW THIS LINE *****/
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int num1, num2, num3, num4, num5;
num1 = in.nextInt();
num2 = in.nextInt();
num3 = in.nextInt();
num4 = in.nextInt();
num5 = in.nextInt();
System.out.println(addOdds(num1, num2, num3, num4, num5));
}
STDOUT
Expected STDOUT
8