Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class smrowfinder {
- public static void main(String[] args) {
- String productneeded = null;
- int productid=0;
- String[] shelves = {"Chocolates", "Biscuits", "Cereals", "Dal", "Vegetables", "Fruits", "Pastry", "Juices", "Fried foods", "Soft drinks"};
- System.out.println("Supermarket Item Finder" + "\n");
- System.out.println("Please enter your current Row no");
- //BufferedReader productBR = new BufferedReader(new InputStreamReader(System.in));
- Scanner crScanner = new Scanner(System.in);
- int crow = crScanner.nextInt();
- System.out.println("Current row =" + crow + "\n");
- System.out.println("Enter the product you are searching for from the below list \n");
- for (int row = 0; row < shelves.length; row++) {
- System.out.println(shelves[row]);
- }
- System.out.println("Product searched for?:");
- productneeded = crScanner.next();
- if(Arrays.asList(shelves).contains(productneeded))
- productid = Arrays.asList(shelves).indexOf(productneeded);
- else
- System.out.println("Please enter a valid item");
- System.out.println("Please find your item at Row no " + productid);
- }
- }
Add Comment
Please, Sign In to add comment