so I've been working on this practice problem and im stuck. help would be much appreciated .
this is what the output should be.
12
30
60
31
90
11
15
Even numbers: 4
Even sum: 192
Odd numbers: 3
Odd sum: 57
and i have to read exactly 7 numbers from the user.
i cant figure out how to get the sum for the even and odd numbers.
this is what i have so far..
import java.util.*; public class practiceLoops { public static void main ( String args[] ) { Scanner scan = new Scanner (System.in); int even = 0; int sumE = 0; int odd = 0; int sumO = 0; int g = 1; int number = scan.nextInt(); while ( g <= 6) { if ( number % 2 == 0) even++; if (number % 2 == 1) odd++; g++; number = scan.nextInt(); } System.out.printf ("even number: %d \n" + "Even sum: %d \n" + "odd numbers %d \n" + "Odd sum %d", even, sumE, odd, sumO); } }