title: Invalid user input asks for input again without switch case/if-else/loops in main()
body: <blockquote>
  <p>This is for basic coding practice.Experience level is beginner.</p>
  </blockquote>
  <p><em>desired output</em>:</p>
  <p>Enter 1-option A Enter 2-option B Enter 3-option C</p>
  <p>*user i/p</p>
  <p>*i/p specific implementation</p>
  <p><em>if any other i/p is received then</em></p>
  <p>Invalid option</p>
  <p>Enter 1-option A, Enter 2-option B, Enter 3-option C</p>
  <p>*user i/p</p>
  <p>----------end of desired o/p------------</p>
  <p><strong>Without using Switch case,Loops,If/else</strong></p>
  <p><em>my code</em></p>
  <pre><code>import java.util.*;
  
  public class Selection {
  
      public static void main(String[] args) {
          System.out.println(&quot;Welcome to ABC Shopping Experience&quot;);
          System.out.println(&quot;Please make selection of items to purchase&quot;);
          System.out.println(&quot;Clothing-1&quot;);
          System.out.println(&quot;Electronics-2&quot;);
          System.out.println(&quot;Sport goods-3&quot;);
  
          new Scan();
          Scan.scan1();
          new Thankyou();
          Thankyou.display(); 
      }
  }
  </code></pre>
  <p>And</p>
  <pre><code>import java.util.Scanner;
  
  public class Scan {
      static Scanner scn = new Scanner(System.in);
      static int first = scn.nextInt();
      static int count = 0;
  
      static Object scan1() {
          if(first == 1) 
              return new Clothing();
          else if (first == 2)
                 return new Electronics();
          else if (first == 3)
              return new Sports();
          else {
                 System.out.println(&quot;Invalid option &quot;);   
              count++;
              
              if(count == 3) {
                  Thankyou t1 = new Thankyou();
                  Thankyou.display();
              } else {
                  scan1();
              }
          }
          count=0;
          return new Thankyou();
      }
  }
  </code></pre>
  <p>and</p>
  <pre><code>import java.util.Scanner;
  
  class Thankyou {
      static void display() {
          System.out.println(&quot;thank you come again&quot;);
       }
  }
  </code></pre>
  <p>-------Output-----</p>
  <pre><code>Welcome to ABC Shopping Experience
  Please make selection of items to purchase
  Clothing-1
  Electronics-2
  Sport goods-3
  6
  Invalid option 
  Invalid option 
  Invalid option 
  thank you come again
  thank you come again
  </code></pre>
  <p>-----END OF OPUTPUT-----</p>
  <p>All classes in same package.</p>
  <p>I understand it is easier with switch/loop but this is the process i want to learn.</p>
  <p>Thank you for your time.</p>