Advertisement
StefanTobler

Lesson 32 Activity 1

Dec 3rd, 2016
516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. /*
  2. * Lesson 32 Coding Activity 1
  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 and prints the month's name.
  10. *
  11. *This method must be called monthName() and it must have an integer parameter.
  12. *
  13. *Calling monthName(8) should print August to the screen.
  14. *
  15. *
  16. */
  17.  
  18.  
  19. import java.util.Scanner;
  20.  
  21. class Lesson_32_Activity_One {
  22.          
  23.        
  24.         public static void monthName(int n)
  25.         {
  26.           String month[] = {"January","February","March","April","May","June","July","August","September","October","November","December"};
  27.           System.out.println(month[n-1]);
  28.         }
  29.      
  30.         public static void main(String[] args)
  31.         {
  32.           Scanner scan = new Scanner(System.in);
  33.           int n = scan.nextInt();
  34.         monthName(n);
  35.         }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement