jbonanno icon

daysAvailable.java

jbonanno | PRO | 06/18/17 07:26:05 PM UTC | 0 ⭐ | 283 👁️ | Never ⏰ | []
Java |

1.07 KB

|

None

|

0 👍

/

0 👎

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vacationprice;
 
/**
 *
 * @author j
 */
import java.io.IOException;
import javax.swing.*;
import java.util.Scanner;   
  
class daysAvailable {   
    
    public static String getMessage (int daySearched) {       
       
        // create array for number of days available
        int[] a={1,4,6,8,9, 12,13,14,18,22,24,25,28,30};   
      
        String s = ""; 
     
        for(int i=0;i<a.length;i++){  
            // if one of the values in the array is the day the user searches for, the day of the array is available
           
            if(a[i]==daySearched){   
              s = ("Day "+daySearched+"is available");    
            break;
        }
            else if(a[i]!=daySearched)
            {   
            
                // if not, the day is not available
    s = ("This day of the month is not available");                
          
            break;
            }
    }   
        
        return s;
        }
}

Comments