viewing paste SentinelValue | Java

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
import javax.swing.JOptionPane; 
 
public  class   SentinelValue{
 
    public  static  void    main(String[] args){
 
        String input = JOptionPane.showInputDialog(null, "Please Enter a number", "Sentinel Value", JOptionPane.QUESTION_MESSAGE);
 
        int data = Integer.parseInt(input);
 
        int calc = data;
 
        while(data != 0){
 
            String inputInt = JOptionPane.showInputDialog(null, "Please Enter a number", "Sentinel Value", JOptionPane.QUESTION_MESSAGE);
 
            data = Integer.parseInt(inputInt);
 
            calc += data;
 
            }
 
            System.out.print("Your result is: "+calc);
 
    }
 
}
Viewed 1253 times, submitted by Streusel.