StefanTobler

Lesson 32 Activity 2

Dec 3rd, 2016
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. /*
  2. * Lesson 32 Coding Activity 2
  3. *
  4. * For the Lesson 32 activities, you will be asked to write one or more methods.
  5. * Use the template to write a main method that tests each of your methods,
  6. * then paste everything into the code runner box. Your submission should
  7. * begin with the first import statement and end with the final }.
  8. *
  9. * Write a method that takes a parameter for the number of a month
  10. * and prints the number of days in the month. Assume that February
  11. * will always have 28 days for this activity.
  12. *
  13. * This method must be called monthDays()and it must take a integer parameter.
  14. *
  15. * Calling monthDays(2) would print 28 and monthDays(9) would print 30.
  16. *
  17. */
  18.  
  19.  
  20. import java.util.Scanner;
  21.  
  22. class Lesson_32_Activity_Two {
  23.          
  24.        
  25.         public static void monthDays(int n)
  26.        
  27.         {
  28.           int[] days = new int[] {31,28,31,30,31,30,31,31,30,31,30,31};
  29.           System.out.println(days[n-1]);
  30.          
  31.         }
  32.      
  33.         public static void main(String[] args)
  34.         {
  35.          Scanner scan = new Scanner(System.in);
  36.          int n = scan.nextInt();
  37.         monthDays(n);
  38.         }
  39. }
Add Comment
Please, Sign In to add comment