i want to find the sum of 10 numbers entered (valid) and also find the no. of valid and non valid nos. entered ....i made the program below but it doesn't work...and need modification in it ?
[code] import java.util.*;
public class EH1 {
public static void main(String[] args){
Scanner s = new Scanner(System.in); int k=1,c=0,sum=0,invalid=0,valid=0;
System.out.println("Enter 10 numbers :");
while (k<=10) { try { c = s.nextInt(); sum =sum + c; valid++; k++; }
catch(NumberFormatException ex)
{ k++; System.out.println(" INVALID NUMBER "); invalid++;