Question: Given two integers, the second larger than the first, this program: * 1) prints the even numbers between the first and second number inclusive *
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 } }
Step by Step Solution
There are 3 Steps involved in it
Here is the full code import javautilScanner public cla... View full answer
Get step-by-step solutions from verified subject matter experts
