Question: Given four positive integers a, b, c, and d, compute the sum of those among them that are odd. Because you have not yet learned

Given four positive integers a, b, c, and d, compute the sum of those among them that are odd.

Because you have not yet learned how to make decisions, use the fact that for a positive integer n, the expression n % 2 is either 0 or 1.

The beginning code is:

public class OddSum
{
public static void main(String[] args)
{
// These values will be changed during testing
int a = 13;
int b = 10;
int c = 9;
int d = 2;

I just need an explanation on where to start as I'm confused on what we're suppose to do. Do I make an initilization for a variable n??? or Do I make one for Oddsum? Please explain.

Step by Step Solution

3.54 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve the problem of computing the sum of odd numbers among the given four integers a b c and d w... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!