Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. /**
  2. * Help! I used too many lines of code. Help me make this more efficient.
  3. * This main method must create an array with the same four words. Then I
  4. * have to test each word using the password method. I have to print a
  5. * message that the password was accepted.
  6. * @param args
  7. */
  8. public static void main(String[] args) {
  9. String[] words = { "Imagine", "yourself", "on", "Mars" };
  10. for(int x = 0; x < words.length; x++) {
  11. if (password(words[x]) == true){
  12. System.out.println("Password accepted");
  13. }
  14. }
  15. }
  16.  
  17. public static boolean password(String w){
  18. return w.equals("Mars");
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement