Question: Complete the OddSum class below, which should add up all the odd integers between two integer bounds. As an example, given the two input bounds

Complete the OddSum class below, which should add up all the odd integers between two integer bounds. As an example, given the two input bounds 3 and 8, the program should compute 3 + 5 + 7 = 15, and print the value 15.

Complete the following file:

OddSum.java

import java.util.Scanner;

/** Computes a sum of odd integers between two bounds. Input: a, the lower bound (may be odd or even). Input: b, the upper bound (may be odd or even). Output: sum of odd integers between a and b (inclusive). */ public class OddSum { public static void main(String[] args) { // Read values for a and b Scanner in = new Scanner(System.in); int a = in.nextInt(); int b = in.nextInt();

// your work here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!