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
Post a Comment