Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Write a JAVA program that accepts 10 integers input by users and outputs the cumulative sum of these 10 integers.
Write a JAVA program that accepts 10 integers input by users and outputs the cumulative sum of these 10 integers.
Import java.io.bufferedreader;

Import java.io.inputstreamreader;

Public class sumTest {

/**

* @param args

*/

Public static void main(String[] args) {

Try {

long sum = 0;

buffered reader reader = new buffered reader(new InputStreamReader(system . in));

for(int I = 0; I< 10; i++){

System.out.print ("Please enter" +(i+ 1)+ "Integer:");

string strNum = reader . readline();

long num = 0;

Try {

num = long . parse long(strNum);

} catch(NumberFormatException e){

System.out.println ("You didn't enter a number, please confirm");

I = I- 1;

}

sum+= num;

}

System.out.println ("The sum of 10 integers you entered is"+sum ");

}catch (exception e) {

e . printstacktrace();

}

}

}