public static void main(String[] args) {
       
        
        // Instantiate a Scanner object
        
        Scanner sc = new Scanner(System.in);
         String choice ="y";
        
        System.out.println("Welcome to the Loan Calculator");
        System.out.println("");
        System.out.println("DATA ENTRY");
        while(choice.equalsIgnoreCase("Y"))
        {
        

          //DATA ENTRY    
          System.out.print("");         
          double loanAmount =getDoublewithinRange(sc,"Enter loan amount: " ,0,1000000);
          double interestRate =getDoublewithinRange(sc,"Enter yearly interest rate:  " ,0,20);
          int numberofYears = getIntWithinRange(sc,"Enter Number of Years: ",0,100);   
             
                 
       //get the total month 
        double months = numberofYears*12;
       
        double interestRateConversion =interestRate/12/100;
        double interestConversion = interestRate/100;
        
        // Calculate  Monthly Payment
        double monthlyPayment = 
                loanAmount * interestRateConversion/
                (1-1/Math.pow(1+interestRateConversion, months));
            
             
        
        // FORMATTED RESULTS
        System.out.println("");
        System.out.println("FORMATTED RESULTS");
        
        //Number Format 
        NumberFormat dollar = NumberFormat.getCurrencyInstance();
        NumberFormat percentage = NumberFormat.getPercentInstance();
        percentage.setMaximumFractionDigits(1);
        dollar.setMaximumFractionDigits(2);
        
      
        //FORMATTED RESULTS
        
        System.out.println("Loan Amount:         "+dollar.format(loanAmount));  
        System.out.println("Yearly Interest Rate:" +percentage.format(interestConversion));
        System.out.println("Number Of Years:     "+numberofYears);  
        System.out.println("Monthly Payment:     "+dollar.format(monthlyPayment));
        
        
  
        
        
        // Prompt the user to continue or not
        boolean  isValid=false;
        while(isValid==false)
            
        {
            System.out.print("Continue? (y/n): ");
            choice=sc.nextLine();
            //sc.nextLine();

            if(choice.isEmpty() && !false) {
               
                 System.out.println("Error! Entry is required. Try again.");
                 continue;}
            else if(choice.equals("y"))
            {
              isValid=true;  
            continue;
            }
            else if (choice.equals("n"))
                         
            {
            break;
            }
           
             else if(!choice.equals("n"))
            {
               System.out.println("Error! Entry must be 'y' or 'n'. Try again");
               continue;

            }
 
        }
                
        }
      
    }