Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. //Author Lervik
  2. //Date 01.09.2014
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class MinOppgave01 {
  7. public static void main (String args[]) {
  8. /*
  9. This file have the task of handling user input and an array. (The user can search the array for a title.)
  10. */
  11.  
  12. String[] titles = {
  13. "Fellowship","Two Towers","Return Of The King","Horebok"
  14. };
  15.  
  16. Scanner in = new Scanner(System.in);
  17. String searchtitle = "";
  18.  
  19. System.out.println("Type the title of a book to see if its in storage");
  20. searchtitle = in.nextLine();
  21.  
  22. for (String title:titles){
  23.  
  24.  
  25. if (title.equalsIgnoreCase(searchtitle)){
  26. System.out.println("The title " + (searchtitle) + " is aviable in storage.");
  27. searchtitle = "";
  28. }
  29.  
  30. else {
  31. System.out.println("The title is not aviable in storage.");
  32. searchtitle = "";
  33. }
  34. }
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement