Guest User

Untitled

a guest
Jul 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. public class smrowfinder {
  2.  
  3. public static void main(String[] args) {
  4. String productneeded = null;
  5. int productid=0;
  6. String[] shelves = {"Chocolates", "Biscuits", "Cereals", "Dal", "Vegetables", "Fruits", "Pastry", "Juices", "Fried foods", "Soft drinks"};
  7. System.out.println("Supermarket Item Finder" + "\n");
  8. System.out.println("Please enter your current Row no");
  9. //BufferedReader productBR = new BufferedReader(new InputStreamReader(System.in));
  10. Scanner crScanner = new Scanner(System.in);
  11. int crow = crScanner.nextInt();
  12. System.out.println("Current row =" + crow + "\n");
  13. System.out.println("Enter the product you are searching for from the below list \n");
  14. for (int row = 0; row < shelves.length; row++) {
  15. System.out.println(shelves[row]);
  16. }
  17. System.out.println("Product searched for?:");
  18. productneeded = crScanner.next();
  19. if(Arrays.asList(shelves).contains(productneeded))
  20. productid = Arrays.asList(shelves).indexOf(productneeded);
  21. else
  22. System.out.println("Please enter a valid item");
  23. System.out.println("Please find your item at Row no " + productid);
  24. }
  25. }
Add Comment
Please, Sign In to add comment