Given two integers, the second larger than the first, this program: * 1) prints the even numbers
Question:
Given two integers, the second larger than the first, this program: * 1) prints the even numbers between the first and second number inclusive * 2) prints the sum of those even numbers * 3) prints the odd numbers between the first and second number inclusive * 4) prints the sum of those odd numbers * * Example: * Enter an integer: 10 * Enter one larger than the first: 20 * Even numbers: 10 12 14 16 18 20 * Sum of even numbers = 90 * Odd numbers: 11 13 15 17 19 * Sum of odd numbers = 75 * * This version uses WHILE loops. * * @author * @version */
import java.util.Scanner; public class WhileLoops { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter an integer: "); int firstNum = in.nextInt(); System.out.print("Enter one larger than the first: "); int secondNum = in.nextInt();
// Complete the program } }
Computer Organization and Design The Hardware Software Interface
ISBN: 978-0124077263
5th edition
Authors: David A. Patterson, John L. Hennessy