java - Adding 3 User Input Numbers together -


i doing exercise site trying add 3 numbers user inputs using 3 variables. code let start off is:

scanner reader = new scanner(system.in); int sum = 0; int read;  // write program here // use variables sum, reader , read!  system.out.println("sum: " + sum); 

i thinking of using loop keep getting stuck because can use 3 variables. reader being used scanner. sum going changing values, , read going temporary value.

i have used

system.out.println("enter number: "); int read = integer.parseint(reader.nextline()); 

but have held 1 number. i've been stuck on while.

this should satisfy requirement:

for(read = 3; read > 0; read--) {     system.out.println("enter number: ");     sum += integer.parseint(reader.nextline()); } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -