Wednesday 24 January 2018

Sentinel in java

import javax.swing.JOptionPane;

public class Sentinel
{
       public static void main(String[] args)
       {
       int input=1;

           while(input !=0 )
           {
           String s1 = JOptionPane.showInputDialog("Enter your choice, 0 to end");
           input = Integer.parseInt(s1);
                  if(input==1)
                  System.out.println("chocolate selected");
                  else
                  if(input==2)
                  System.out.println("Candy selected");
                  else
                  System.out.println("Nothing selected");
           }
       }
 }

0 comments: