Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

add infinite numbers to variable java

	Scanner sc = new Scanner(System.in);
	int value = 0;
	int total = 0;

    //adds a number to the total variable every occurence of the loop
		
	for (;;) {
			
		System.out.println("Enter a number");
		value = sc.nextInt();
			
		total += value;
			
		System.out.println("You added " + value + " to the total");
		System.out.println("The total is " + total + " so far");
			
		value = 0;		
			
	}
 
PREVIOUS NEXT
Tagged: #add #infinite #numbers #variable #java
ADD COMMENT
Topic
Name
1+3 =