Please enter three integer values:
12 15 3
The sum of these numbers is:30
this is how my output suppose to look like, am using Jcreator (JAVA), the values must be added using a loop.Values come from user as well
1
Expert's answer
2011-06-24T07:37:33-0400
import java.util.Scanner;
public class Task { & public static void main(String[] args) & { int result = 0; Scanner scan = new Scanner(System.in); System.out.println("Please enter three integer values:"); for(int i = 0; i < 3; i++) { if(scan.hasNextInt()) { & result += scan.nextInt(); } } System.out.println("The sum of these numbers is:"+result); & } }
Comments
Leave a comment