Advertisement
jbonanno

daysAvailable.java

Jun 18th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package vacationprice;
  6.  
  7. /**
  8.  *
  9.  * @author j
  10.  */
  11. import java.io.IOException;
  12. import javax.swing.*;
  13. import java.util.Scanner;  
  14.  
  15. class daysAvailable {  
  16.    
  17.     public static String getMessage (int daySearched) {      
  18.        
  19.         // create array for number of days available
  20.         int[] a={1,4,6,8,9, 12,13,14,18,22,24,25,28,30};  
  21.      
  22.         String s = "";
  23.      
  24.         for(int i=0;i<a.length;i++){  
  25.             // if one of the values in the array is the day the user searches for, the day of the array is available
  26.            
  27.             if(a[i]==daySearched){  
  28.               s = ("Day "+daySearched+"is available");    
  29.             break;
  30.         }
  31.             else if(a[i]!=daySearched)
  32.             {  
  33.            
  34.                 // if not, the day is not available
  35.     s = ("This day of the month is not available");                
  36.          
  37.             break;
  38.             }
  39.     }  
  40.        
  41.         return s;
  42.         }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement