Facebook
From KasiaKAsia, 1 Week ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 25
  1. import java.util.Scanner;
  2.  
  3. public class SentinelSum {
  4.     public static void main(String[] args) {
  5.         int number, suma=1;
  6.         Scanner sc = new Scanner(System.in);  
  7.         do {
  8.             System.out.print("Type a number: ");
  9.             number = sc.nextInt();
  10.             suma += number;
  11.         } while (number != -1);    
  12.         System.out.print("Sum is " + suma);
  13.     }
  14. }